Skip to contentSkip to conversation

armada: no need to check return value of debugfs_create functions

PATCH In review Greg Kroah-Hartman 2 participants 5 messages Jun 13, 2019

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

PATCH 1/1 armada: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

---
 drivers/gpu/drm/armada/armada_debugfs.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/armada/armada_debugfs.c +4 -10
index 6758c3a83de2..aec1e7372371 100644
@@ -109,7 +109,6 @@ static struct drm_info_list armada_debugfs_list[] = {
 
 int armada_drm_debugfs_init(struct drm_minor *minor)
 {
-	struct dentry *de;
 	int ret;
 
 	ret = drm_debugfs_create_files(armada_debugfs_list,
@@ -118,15 +117,10 @@ int armada_drm_debugfs_init(struct drm_minor *minor)
 	if (ret)
 		return ret;
 
-	de = debugfs_create_file("reg", S_IFREG | S_IRUSR,
-				 minor->debugfs_root, minor->dev, &fops_reg_r);
-	if (!de)
-		return -ENOMEM;
-
-	de = debugfs_create_file("reg_wr", S_IFREG | S_IWUSR,
-				 minor->debugfs_root, minor->dev, &fops_reg_w);
-	if (!de)
-		return -ENOMEM;
+	debugfs_create_file("reg", S_IFREG | S_IRUSR, minor->debugfs_root,
+			    minor->dev, &fops_reg_r);
+	debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, minor->debugfs_root,
+			    minor->dev, &fops_reg_w);
 
 	return 0;
 }
Signature · 6 lines
2.22.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 3 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Please don't merge this patch - I have a change that conflicts with this which switches us over to using drm_debugfs_create_files(), thereby eliminating this code.

Quoted 46 lines
---
 drivers/gpu/drm/armada/armada_debugfs.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/armada/armada_debugfs.c +4 -10
index 6758c3a83de2..aec1e7372371 100644
@@ -109,7 +109,6 @@ static struct drm_info_list armada_debugfs_list[] = {
 
 int armada_drm_debugfs_init(struct drm_minor *minor)
 {
-	struct dentry *de;
 	int ret;
 
 	ret = drm_debugfs_create_files(armada_debugfs_list,
@@ -118,15 +117,10 @@ int armada_drm_debugfs_init(struct drm_minor *minor)
 	if (ret)
 		return ret;
 
-	de = debugfs_create_file("reg", S_IFREG | S_IRUSR,
-				 minor->debugfs_root, minor->dev, &fops_reg_r);
-	if (!de)
-		return -ENOMEM;
-
-	de = debugfs_create_file("reg_wr", S_IFREG | S_IWUSR,
-				 minor->debugfs_root, minor->dev, &fops_reg_w);
-	if (!de)
-		return -ENOMEM;
+	debugfs_create_file("reg", S_IFREG | S_IRUSR, minor->debugfs_root,
+			    minor->dev, &fops_reg_r);
+	debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, minor->debugfs_root,
+			    minor->dev, &fops_reg_w);
 
 	return 0;
 }
Signature · 1 line
2.22.0
Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 8 lines · Russell King - ARM Linux admin
Quoted 3 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Please don't merge this patch - I have a change that conflicts with this which switches us over to using drm_debugfs_create_files(), thereby eliminating this code.

Isn't it "first received, first applied?" That's how it is for my subsystems...

Anyway, I have a much larger patch for all users of drm_debugfs_create_files coming, but I'll wait for all of these tiny ones to land before sending that out :)

thanks,

greg k-h
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Russell King - ARM Linux admin
Quoted 3 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Quoted 6 lines
Quoted 3 lines

Please don't merge this patch - I have a change that conflicts with this which switches us over to using drm_debugfs_create_files(), thereby eliminating this code.

Isn't it "first received, first applied?" That's how it is for my subsystems...

When I started working on the kernel in the 1990s, it was "the most technically correct approach of competing approaches". If we've now switched to "first received, first applied" that can only be harmful and demotivating to those who wish to do a good job.

If someone has a better approach ready to go, why should the inferior approach be applied and then the better approach have to be rebased on top of the inferior approach? This makes no sense.

Signature · 7 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 14 lines · Russell King - ARM Linux admin
Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Russell King - ARM Linux admin
Quoted 3 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Quoted 6 lines
Quoted 3 lines

Please don't merge this patch - I have a change that conflicts with this which switches us over to using drm_debugfs_create_files(), thereby eliminating this code.

Isn't it "first received, first applied?" That's how it is for my subsystems...

Quoted 8 lines

When I started working on the kernel in the 1990s, it was "the most technically correct approach of competing approaches". If we've now switched to "first received, first applied" that can only be harmful and demotivating to those who wish to do a good job.

If someone has a better approach ready to go, why should the inferior approach be applied and then the better approach have to be rebased on top of the inferior approach? This makes no sense.

If you have a better approach ready to go, please post it and I will be glad to rebase my patch on top of yours.

greg k-h
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel