Skip to contentSkip to conversation

arm: mach-tegra: check wether we have debugfs enabled or not

PATCH In review Devendra Naga 3 participants 5 messages Oct 17, 2012 3 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mach-tegra: check wether we have debugfs enabled or not

if debugfs is not enabled in kernel it returns -ENODEV, check it with IS_ERR_OR_NULL along with the null return if it fails to create a file in debugfs.

---
 arch/arm/mach-tegra/powergate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-tegra/powergate.c +1 -1
index de0662d..1809b91d 100644
@@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
 	if (powergate_name) {
 		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
 			&powergate_fops);
-		if (!d)
+		if (IS_ERR_OR_NULL(d))
 			return -ENOMEM;
 	}
 
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to a message not in the archive
Quoted 14 lines · Devendra Naga

if debugfs is not enabled in kernel it returns -ENODEV, check it with IS_ERR_OR_NULL along with the null return if it fails to create a file in debugfs.

---
 arch/arm/mach-tegra/powergate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-tegra/powergate.c +0 -0
index de0662d..1809b91d 100644

arch/arm/mach-tegra/powergate.c int __init tegra_powergate_debugfs_init(void) · line 273

Quoted 6 lines
arch/arm/mach-tegra/powergate.c +1 -1
@@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
 	if (powergate_name) {
 		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
 			&powergate_fops);
-		if (!d)
+		if (IS_ERR_OR_NULL(d))
 			return -ENOMEM;

So, you want to make this function hard-fail if a debugfs error occurs _or_ debugfs is not configured? That doesn't seem to be a clever thing to do.

#4 lore raw
In reply to a message not in the archive
Quoted 4 lines · Russell King - ARM Linux

So, you want to make this function hard-fail if a debugfs error occurs _or_ debugfs is not configured? That doesn't seem to be a clever thing to do.

I was seeing some places where the check is only for the pointer null or valid one that is returned by
the debugfs_create_file, and fixed it up using this macro by failing out even if we dont have debugfs
enabled in kernel.

I am sure that i really dont' know any part of the ARM stuff, tried to fix this too, because this function
also checks for the null pointer if debugfs_create_file failed to create a file in debugfs and fails out if
it can't be able to create that, but it wont check for whether we have debugfs enabled in kernel.

thanks,

#5 lore raw
In reply to a message not in the archive
Quoted 10 lines · Russell King - ARM Linux
Quoted 9 lines · Devendra Naga

if debugfs is not enabled in kernel it returns -ENODEV, check it with IS_ERR_OR_NULL along with the null return if it fails to create a file in debugfs.

---
 arch/arm/mach-tegra/powergate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

arch/arm/mach-tegra/powergate.c int __init tegra_powergate_debugfs_init(void) · line 273

Quoted 11 lines
arch/arm/mach-tegra/powergate.c +1 -1
index de0662d..1809b91d 100644
@@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
 	if (powergate_name) {
 		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
 			&powergate_fops);
-		if (!d)
+		if (IS_ERR_OR_NULL(d))
 			return -ENOMEM;

So, you want to make this function hard-fail if a debugfs error occurs _or_ debugfs is not configured? That doesn't seem to be a clever thing to do.

In practice, that quoted chunk of code is inside an #ifdef CONFIG_DEBUG_FS, so according to the documentation for debugfs_create_file(), the IS_ERR case of IS_ERR_OR_NULL cannot happen here. So, the above change is a no-op, so there's not much point applying it.

#7 lore raw
In reply to a message not in the archive
Quoted 27 lines · Stephen Warren
Quoted 10 lines · Russell King - ARM Linux
Quoted 9 lines · Devendra Naga

if debugfs is not enabled in kernel it returns -ENODEV, check it with IS_ERR_OR_NULL along with the null return if it fails to create a file in debugfs.

---
 arch/arm/mach-tegra/powergate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

arch/arm/mach-tegra/powergate.c int __init tegra_powergate_debugfs_init(void) · line 273

Quoted 11 lines
arch/arm/mach-tegra/powergate.c +1 -1
index de0662d..1809b91d 100644
@@ -269,7 +269,7 @@ int __init tegra_powergate_debugfs_init(void)
 	if (powergate_name) {
 		d = debugfs_create_file("powergate", S_IRUGO, NULL, NULL,
 			&powergate_fops);
-		if (!d)
+		if (IS_ERR_OR_NULL(d))
 			return -ENOMEM;

So, you want to make this function hard-fail if a debugfs error occurs _or_ debugfs is not configured? That doesn't seem to be a clever thing to do.

Quoted 5 lines

In practice, that quoted chunk of code is inside an #ifdef CONFIG_DEBUG_FS, so according to the documentation for debugfs_create_file(), the IS_ERR case of IS_ERR_OR_NULL cannot happen here. So, the above change is a no-op, so there's not much point applying it.

Ok. Another reason not to apply it is that should the ifdefs get removed, it'll start failing when debugfs is disabled with -ENOMEM, which isn't bright. A further reason is it's another place that'd need reviewing for bad usage of the IS_ERR_OR_NULL() problem I've pointed out this evening.