Skip to contentSkip to conversation

mic: no need to check return value of debugfs_create functions

PATCH In review Greg Kroah-Hartman 3 participants 3 messages Jun 11, 2019 – Jun 12, 2019 Char and misc drivers

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/1 mic: 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/misc/mic/card/mic_debugfs.c  | 18 ++----------------
 drivers/misc/mic/cosm/cosm_debugfs.c |  4 ----
 drivers/misc/mic/host/mic_debugfs.c  |  4 ----
 drivers/misc/mic/scif/scif_debugfs.c |  5 -----
 drivers/misc/mic/vop/vop_debugfs.c   |  4 ----
 5 files changed, 2 insertions(+), 33 deletions(-)
drivers/misc/mic/card/mic_debugfs.c +2 -16
index 7a4140874888..fa2b5fefb791 100644
@@ -63,25 +63,13 @@ DEFINE_SHOW_ATTRIBUTE(mic_intr);
  */
 void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
 {
-	struct dentry *d;
-
 	if (!mic_dbg)
 		return;
 
 	mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
-	if (!mdrv->dbg_dir) {
-		dev_err(mdrv->dev, "Cant create dbg_dir %s\n", mdrv->name);
-		return;
-	}
-
-	d = debugfs_create_file("intr_test", 0444, mdrv->dbg_dir,
-		mdrv, &mic_intr_fops);
 
-	if (!d) {
-		dev_err(mdrv->dev,
-			"Cant create dbg intr_test %s\n", mdrv->name);
-		return;
-	}
+	debugfs_create_file("intr_test", 0444, mdrv->dbg_dir, mdrv,
+			    &mic_intr_fops);
 }
 
 /**
@@ -101,8 +89,6 @@ void mic_delete_card_debug_dir(struct mic_driver *mdrv)
 void __init mic_init_card_debugfs(void)
 {
 	mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!mic_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 /**
drivers/misc/mic/cosm/cosm_debugfs.c +0 -4
index 71c216d0504d..340ea7171411 100644
@@ -105,8 +105,6 @@ void cosm_create_debug_dir(struct cosm_device *cdev)
 
 	scnprintf(name, sizeof(name), "mic%d", cdev->index);
 	cdev->dbg_dir = debugfs_create_dir(name, cosm_dbg);
-	if (!cdev->dbg_dir)
-		return;
 
 	debugfs_create_file("log_buf", 0444, cdev->dbg_dir, cdev,
 			    &log_buf_fops);
@@ -125,8 +123,6 @@ void cosm_delete_debug_dir(struct cosm_device *cdev)
 void cosm_init_debugfs(void)
 {
 	cosm_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!cosm_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 void cosm_exit_debugfs(void)
drivers/misc/mic/host/mic_debugfs.c +0 -4
index c6e3c764699f..370f98c7b752 100644
@@ -125,8 +125,6 @@ void mic_create_debug_dir(struct mic_device *mdev)
 
 	scnprintf(name, sizeof(name), "mic%d", mdev->id);
 	mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
-	if (!mdev->dbg_dir)
-		return;
 
 	debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
 			    &mic_smpt_fops);
@@ -155,8 +153,6 @@ void mic_delete_debug_dir(struct mic_device *mdev)
 void __init mic_init_debugfs(void)
 {
 	mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!mic_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 /**
drivers/misc/mic/scif/scif_debugfs.c +0 -5
index a6820480105a..8fe38e7ca6e6 100644
@@ -103,11 +103,6 @@ DEFINE_SHOW_ATTRIBUTE(scif_rma);
 void __init scif_init_debugfs(void)
 {
 	scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!scif_dbg) {
-		dev_err(scif_info.mdev.this_device,
-			"can't create debugfs dir scif\n");
-		return;
-	}
 
 	debugfs_create_file("scif_dev", 0444, scif_dbg, NULL, &scif_dev_fops);
 	debugfs_create_file("scif_rma", 0444, scif_dbg, NULL, &scif_rma_fops);
drivers/misc/mic/vop/vop_debugfs.c +0 -4
index 2ccef52aca23..d4551d522188 100644
@@ -186,10 +186,6 @@ void vop_init_debugfs(struct vop_info *vi)
 
 	snprintf(name, sizeof(name), "%s%d", KBUILD_MODNAME, vi->vpdev->dnode);
 	vi->dbg = debugfs_create_dir(name, NULL);
-	if (!vi->dbg) {
-		pr_err("can't create debugfs dir vop\n");
-		return;
-	}
 	debugfs_create_file("dp", 0444, vi->dbg, vi, &vop_dp_fops);
 	debugfs_create_file("vdev_info", 0444, vi->dbg, vi, &vop_vdev_info_fops);
 }
Signature · 1 line
2.22.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 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.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Greg Kroah-Hartman
Quoted 4 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.

Thanks Greg.

Quoted 129 lines
---
 drivers/misc/mic/card/mic_debugfs.c  | 18 ++----------------
 drivers/misc/mic/cosm/cosm_debugfs.c |  4 ----
 drivers/misc/mic/host/mic_debugfs.c  |  4 ----
 drivers/misc/mic/scif/scif_debugfs.c |  5 -----
 drivers/misc/mic/vop/vop_debugfs.c   |  4 ----
 5 files changed, 2 insertions(+), 33 deletions(-)
drivers/misc/mic/card/mic_debugfs.c +2 -16
index 7a4140874888..fa2b5fefb791 100644
@@ -63,25 +63,13 @@ DEFINE_SHOW_ATTRIBUTE(mic_intr);
  */
 void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
 {
-	struct dentry *d;
-
 	if (!mic_dbg)
 		return;
 
 	mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
-	if (!mdrv->dbg_dir) {
-		dev_err(mdrv->dev, "Cant create dbg_dir %s\n", mdrv->name);
-		return;
-	}
-
-	d = debugfs_create_file("intr_test", 0444, mdrv->dbg_dir,
-		mdrv, &mic_intr_fops);
 
-	if (!d) {
-		dev_err(mdrv->dev,
-			"Cant create dbg intr_test %s\n", mdrv->name);
-		return;
-	}
+	debugfs_create_file("intr_test", 0444, mdrv->dbg_dir, mdrv,
+			    &mic_intr_fops);
 }
 
 /**
@@ -101,8 +89,6 @@ void mic_delete_card_debug_dir(struct mic_driver *mdrv)
 void __init mic_init_card_debugfs(void)
 {
 	mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!mic_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 /**
drivers/misc/mic/cosm/cosm_debugfs.c +0 -4
index 71c216d0504d..340ea7171411 100644
@@ -105,8 +105,6 @@ void cosm_create_debug_dir(struct cosm_device *cdev)
 
 	scnprintf(name, sizeof(name), "mic%d", cdev->index);
 	cdev->dbg_dir = debugfs_create_dir(name, cosm_dbg);
-	if (!cdev->dbg_dir)
-		return;
 
 	debugfs_create_file("log_buf", 0444, cdev->dbg_dir, cdev,
 			    &log_buf_fops);
@@ -125,8 +123,6 @@ void cosm_delete_debug_dir(struct cosm_device *cdev)
 void cosm_init_debugfs(void)
 {
 	cosm_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!cosm_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 void cosm_exit_debugfs(void)
drivers/misc/mic/host/mic_debugfs.c +0 -4
index c6e3c764699f..370f98c7b752 100644
@@ -125,8 +125,6 @@ void mic_create_debug_dir(struct mic_device *mdev)
 
 	scnprintf(name, sizeof(name), "mic%d", mdev->id);
 	mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
-	if (!mdev->dbg_dir)
-		return;
 
 	debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
 			    &mic_smpt_fops);
@@ -155,8 +153,6 @@ void mic_delete_debug_dir(struct mic_device *mdev)
 void __init mic_init_debugfs(void)
 {
 	mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!mic_dbg)
-		pr_err("can't create debugfs dir\n");
 }
 
 /**
drivers/misc/mic/scif/scif_debugfs.c +0 -5
index a6820480105a..8fe38e7ca6e6 100644
@@ -103,11 +103,6 @@ DEFINE_SHOW_ATTRIBUTE(scif_rma);
 void __init scif_init_debugfs(void)
 {
 	scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-	if (!scif_dbg) {
-		dev_err(scif_info.mdev.this_device,
-			"can't create debugfs dir scif\n");
-		return;
-	}
 
 	debugfs_create_file("scif_dev", 0444, scif_dbg, NULL, &scif_dev_fops);
 	debugfs_create_file("scif_rma", 0444, scif_dbg, NULL, &scif_rma_fops);
drivers/misc/mic/vop/vop_debugfs.c +0 -4
index 2ccef52aca23..d4551d522188 100644
@@ -186,10 +186,6 @@ void vop_init_debugfs(struct vop_info *vi)
 
 	snprintf(name, sizeof(name), "%s%d", KBUILD_MODNAME, vi->vpdev->dnode);
 	vi->dbg = debugfs_create_dir(name, NULL);
-	if (!vi->dbg) {
-		pr_err("can't create debugfs dir vop\n");
-		return;
-	}
 	debugfs_create_file("dp", 0444, vi->dbg, vi, &vop_dp_fops);
 	debugfs_create_file("vdev_info", 0444, vi->dbg, vi, &vop_vdev_info_fops);
 }