Skip to contentSkip to conversation

ARM: OMAP3+: PM debug: fix the use of debugfs_create_* API

PATCH New Jean Pihet 2 participants 5 messages Jan 31, 2012 – Feb 1, 2012

Subsystems (4)
lore
Share & tools
lore

Jean Pihet

author
#0 lore raw

PATCH 1/1 ARM: OMAP3+: PM debug: fix the use of debugfs_create_* API

The debugfs_create_* API returns a NULL ptr in case of problem. Fix the PM debug code to take this into account.

---
 arch/arm/mach-omap2/pm-debug.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/pm-debug.c +2 -2
index 4411163..e5bf367 100644
@@ -264,8 +264,8 @@ static int __init pm_dbg_init(void)
 		return 0;
 
 	d = debugfs_create_dir("pm_debug", NULL);
-	if (IS_ERR(d))
-		return PTR_ERR(d);
+	if (!d)
+		return -ENOMEM;
 
 	(void) debugfs_create_file("count", S_IRUGO,
 		d, (void *)DEBUG_FILE_COUNTERS, &debug_fops);
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 ARM: OMAP3+: PM debug: fix the use of debugfs_create_* API

Quoted 13 lines · Jean Pihet

The debugfs_create_* API returns a NULL ptr in case of problem. Fix the PM debug code to take this into account.

---
 arch/arm/mach-omap2/pm-debug.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/pm-debug.c +0 -0
index 4411163..e5bf367 100644

arch/arm/mach-omap2/pm-debug.c static int __init pm_dbg_init(void) · line 267

Quoted 6 lines
arch/arm/mach-omap2/pm-debug.c +1 -2
@@ -264,8 +264,8 @@ static int __init pm_dbg_init(void)
 		return 0;
 
 	d = debugfs_create_dir("pm_debug", NULL);
-	if (IS_ERR(d))
-		return PTR_ERR(d);
+	if (!d)

I think this should be IS_ERR_OR_NULL() because this function can also return ERR_PTR(-ENODEV). (Yes, only when debugfs is not enabled, but it's still more correct.)

Kevin

Quoted 3 lines
arch/arm/mach-omap2/pm-debug.c +1 -0
+		return -ENOMEM;
 	(void) debugfs_create_file("count", S_IRUGO,
 		d, (void *)DEBUG_FILE_COUNTERS, &debug_fops);
author
#2 lore raw

PATCH 1/1 ARM: OMAP3+: PM debug: fix the use of debugfs_create_* API

Kevin,

Quoted 17 lines · Kevin Hilman
Quoted 15 lines · Jean Pihet

The debugfs_create_* API returns a NULL ptr in case of problem. Fix the PM debug code to take this into account.

---
?arch/arm/mach-omap2/pm-debug.c | ? ?4 ++--
?1 files changed, 2 insertions(+), 2 deletions(-)

arch/arm/mach-omap2/pm-debug.c +0 -0
index 4411163..e5bf367 100644
@@ -264,8 +264,8 @@ static int __init pm_dbg_init(void)
 ? ? ? ? ? ? ? return 0;
 
Quoted 8 lines

arch/arm/mach-omap2/pm-debug.c static int __init pm_dbg_init(void) · line 267

Quoted 4 lines
arch/arm/mach-omap2/pm-debug.c +1 -2
 ? ? ? d = debugfs_create_dir("pm_debug", NULL);
- ? ? if (IS_ERR(d))
- ? ? ? ? ? ? return PTR_ERR(d);
+ ? ? if (!d)

I think this should be IS_ERR_OR_NULL() because this function can also return ERR_PTR(-ENODEV). ?(Yes, only when debugfs is not enabled, but it's still more correct.)

That makes sense, even if the PM debug code is enclosed by #ifdef CONFIG_DEBUG_FS.
I have a new version of the patch, it also fixes another potential problem with debugfs.

Thanks,
Jean

Quoted 3 lines

Kevin

author
#3 lore raw

PATCH 1/1 ARM: OMAP2+: PM debug: fix the use of debugfs_create_* API

In reply to Jean Pihet

Check the return code pointer value from debugfs_create_dir for error or NULL.
Also added an additional check to prevent the creation of a 'suspend' entry at the debugfs root in case a power domain directory cannot be created.

---
 arch/arm/mach-omap2/pm-debug.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-omap2/pm-debug.c +3 -3
index 4411163..814bcd9 100644
@@ -220,8 +220,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)
 		return 0;
 
 	d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir);
-
-	(void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d,
+	if (!(IS_ERR_OR_NULL(d)))
+		(void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d,
 			(void *)pwrdm, &pwrdm_suspend_fops);
 
 	return 0;
@@ -264,7 +264,7 @@ static int __init pm_dbg_init(void)
 		return 0;
 
 	d = debugfs_create_dir("pm_debug", NULL);
-	if (IS_ERR(d))
+	if (IS_ERR_OR_NULL(d))
 		return PTR_ERR(d);
 
 	(void) debugfs_create_file("count", S_IRUGO,
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 1/1 ARM: OMAP2+: PM debug: fix the use of debugfs_create_* API

Quoted 7 lines · Jean Pihet

Check the return code pointer value from debugfs_create_dir for error or NULL.
Also added an additional check to prevent the creation of a 'suspend' entry at the debugfs root in case a power domain directory cannot be created.

Thanks, queing for v3.4.

Kevin