diff mbox series

[-next,v2] mtip32xx: Remove redundant null pointer checks in mtip_hw_debugfs_init()

Message ID 20240907034046.3595268-1-lizetao1@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,v2] mtip32xx: Remove redundant null pointer checks in mtip_hw_debugfs_init() | expand

Commit Message

lizetao Sept. 7, 2024, 3:40 a.m. UTC
Since the debugfs_create_dir() never returns a null pointer, checking
the return value for a null pointer is redundant. Since
debugfs_create_file() can deal with a ERR_PTR() style pointer, drop
the check.  Since mtip_hw_debugfs_init does not pay attention to the
return value, its return type can be changed to void.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v1 -> v2: Directly delete the check on the return value of
debugfs_create_dir
v1:
https://lore.kernel.org/all/20240903144354.2005690-1-lizetao1@huawei.com/

 drivers/block/mtip32xx/mtip32xx.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

Comments

Jens Axboe Sept. 8, 2024, 2:56 p.m. UTC | #1
On Sat, 07 Sep 2024 11:40:46 +0800, Li Zetao wrote:
> Since the debugfs_create_dir() never returns a null pointer, checking
> the return value for a null pointer is redundant. Since
> debugfs_create_file() can deal with a ERR_PTR() style pointer, drop
> the check.  Since mtip_hw_debugfs_init does not pay attention to the
> return value, its return type can be changed to void.
> 
> 
> [...]

Applied, thanks!

[1/1] mtip32xx: Remove redundant null pointer checks in mtip_hw_debugfs_init()
      commit: a02e98bebc15f1d973c2a62005be9456a657e2b6

Best regards,
diff mbox series

Patch

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index c6ef0546ffc9..11901f2812ad 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -2269,25 +2269,12 @@  static const struct file_operations mtip_flags_fops = {
 	.llseek = no_llseek,
 };
 
-static int mtip_hw_debugfs_init(struct driver_data *dd)
+static void mtip_hw_debugfs_init(struct driver_data *dd)
 {
-	if (!dfs_parent)
-		return -1;
-
 	dd->dfs_node = debugfs_create_dir(dd->disk->disk_name, dfs_parent);
-	if (IS_ERR_OR_NULL(dd->dfs_node)) {
-		dev_warn(&dd->pdev->dev,
-			"Error creating node %s under debugfs\n",
-						dd->disk->disk_name);
-		dd->dfs_node = NULL;
-		return -1;
-	}
-
 	debugfs_create_file("flags", 0444, dd->dfs_node, dd, &mtip_flags_fops);
 	debugfs_create_file("registers", 0444, dd->dfs_node, dd,
 			    &mtip_regs_fops);
-
-	return 0;
 }
 
 static void mtip_hw_debugfs_exit(struct driver_data *dd)
@@ -4043,10 +4030,6 @@  static int __init mtip_init(void)
 	mtip_major = error;
 
 	dfs_parent = debugfs_create_dir("rssd", NULL);
-	if (IS_ERR_OR_NULL(dfs_parent)) {
-		pr_warn("Error creating debugfs parent\n");
-		dfs_parent = NULL;
-	}
 
 	/* Register our PCI operations. */
 	error = pci_register_driver(&mtip_pci_driver);