Skip to contentSkip to conversation

ASoC: soc-core: Fix checking return value of debugfs_create_dir

PATCH In review Axel Lin 2 participants 2 messages Aug 14, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: soc-core: Fix checking return value of debugfs_create_dir

We have CONFIG_DEBUG_FS guard around the place calling debugfs_create_dir, thus debugfs_create_dir returns NULL on failure.

Also use pr_warn to print the warning.

---
 sound/soc/soc-core.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
sound/soc/soc-core.c +2 -5
index ae93aa8..69d17ec 100644
@@ -3356,11 +3356,8 @@ static int __init snd_soc_init(void)
 {
 #ifdef CONFIG_DEBUG_FS
 	snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
-	if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) {
-		printk(KERN_WARNING
-		       "ASoC: Failed to create debugfs directory\n");
-		snd_soc_debugfs_root = NULL;
-	}
+	if (!snd_soc_debugfs_root)
+		pr_warn("ASoC: Failed to create debugfs directory\n");
 
 	if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL,
 				 &codec_list_fops))
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 2 lines · Axel Lin

We have CONFIG_DEBUG_FS guard around the place calling debugfs_create_dir, thus debugfs_create_dir returns NULL on failure.

On the other hand the existing code doesn't actually have any problem, the IS_ERR() won't give false positives, so the changelog isn't really accurate and if anything we'll introduce a bug if someone cut'n'pastes the code elsewhere.