Skip to contentSkip to conversation

bna: Remove error checking for debugfs create APIs

PATCH Applied Zhen Lei 2 participants 4 messages Oct 28, 2024 – Oct 31, 2024

Subsystems (3)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

v3 cover bna: Remove error checking for debugfs create APIs

v2 --> v3:
1. Keep line wrapping <= 80 columns wide.
2. Add Reviewed-by: Simon Horman <[email protected]>

v1 --> v2:
Remove error checking for debugfs_create_file() instead of fixing it.

v1:
1. Fix the incorrect return value check for debugfs_create_dir() and debugfs_create_file(), which returns ERR_PTR(-ERROR) instead of NULL when it fails.
2. Remove field bnad_dentry_files[] in struct bnad. When a directory is deleted, files in the directory are automatically deleted. Therefore, there is need to record these files.

Zhen Lei (2):
bna: Remove error checking for debugfs create APIs
bna: Remove field bnad_dentry_files[] in struct bnad

 drivers/net/ethernet/brocade/bna/bnad.h       |  1 -
 .../net/ethernet/brocade/bna/bnad_debugfs.c   | 31 +++----------------
 2 files changed, 5 insertions(+), 27 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v3 1/2 bna: Remove error checking for debugfs create APIs

Driver bna can work fine even if any previous call to debugfs create APIs failed. All return value checks of them should be dropped, as debugfs APIs say.

---
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/net/ethernet/brocade/bna/bnad_debugfs.c +0 -11
index 97291bfbeea589e..1a3a8bd133706ad 100644
@@ -500,11 +500,6 @@ bnad_debugfs_init(struct bnad *bnad)
 	if (!bna_debugfs_root) {
 		bna_debugfs_root = debugfs_create_dir("bna", NULL);
 		atomic_set(&bna_debugfs_port_count, 0);
-		if (!bna_debugfs_root) {
-			netdev_warn(bnad->netdev,
-				    "debugfs root dir creation failed\n");
-			return;
-		}
 	}
 
 	/* Setup the pci_dev debugfs directory for the port */
@@ -523,12 +518,6 @@ bnad_debugfs_init(struct bnad *bnad)
 							bnad->port_debugfs_root,
 							bnad,
 							file->fops);
-			if (!bnad->bnad_dentry_files[i]) {
-				netdev_warn(bnad->netdev,
-					    "create %s entry failed\n",
-					    file->name);
-				return;
-			}
 		}
 	}
 }
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v3 2/2 bna: Remove field bnad_dentry_files[] in struct bnad

In reply to Zhen Lei

Function debugfs_remove() recursively removes a directory, include all files created by debugfs_create_file(). Therefore, there is no need to explicitly record each file with member ->bnad_dentry_files[] and explicitly delete them at the end. Remove field bnad_dentry_files[] and its related processing codes for simplification.

---
 drivers/net/ethernet/brocade/bna/bnad.h       |  1 -
 .../net/ethernet/brocade/bna/bnad_debugfs.c   | 20 +++++--------------
 2 files changed, 5 insertions(+), 16 deletions(-)
drivers/net/ethernet/brocade/bna/bnad.h +0 -1
index 10b1e534030e628..4396997c59d041f 100644
@@ -351,7 +351,6 @@ struct bnad {
 	/* debugfs specific data */
 	char	*regdata;
 	u32	reglen;
-	struct dentry *bnad_dentry_files[5];
 	struct dentry *port_debugfs_root;
 };
 
drivers/net/ethernet/brocade/bna/bnad_debugfs.c +5 -15
index 1a3a8bd133706ad..8f0972e6737c12d 100644
@@ -512,12 +512,11 @@ bnad_debugfs_init(struct bnad *bnad)
 
 		for (i = 0; i < ARRAY_SIZE(bnad_debugfs_files); i++) {
 			file = &bnad_debugfs_files[i];
-			bnad->bnad_dentry_files[i] =
-					debugfs_create_file(file->name,
-							file->mode,
-							bnad->port_debugfs_root,
-							bnad,
-							file->fops);
+			debugfs_create_file(file->name,
+					    file->mode,
+					    bnad->port_debugfs_root,
+					    bnad,
+					    file->fops);
 		}
 	}
 }
@@ -526,15 +525,6 @@ bnad_debugfs_init(struct bnad *bnad)
 void
 bnad_debugfs_uninit(struct bnad *bnad)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(bnad_debugfs_files); i++) {
-		if (bnad->bnad_dentry_files[i]) {
-			debugfs_remove(bnad->bnad_dentry_files[i]);
-			bnad->bnad_dentry_files[i] = NULL;
-		}
-	}
-
 	/* Remove the pci_dev debugfs directory for the port */
 	if (bnad->port_debugfs_root) {
 		debugfs_remove(bnad->port_debugfs_root);
Signature · 1 line
2.34.1
#3 lore raw
In reply to Zhen Lei
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 28 Oct 2024 10:09:41 +0800 you wrote:

v2 --> v3:
1. Keep line wrapping <= 80 columns wide.
2. Add Reviewed-by: Simon Horman <[email protected]>

v1 --> v2:
Remove error checking for debugfs_create_file() instead of fixing it.

[...]

Here is the summary with links:
- [v3,1/2] bna: Remove error checking for debugfs create APIs

    https://git.kernel.org/netdev/net-next/c/bf8207ec8c30
  - [v3,2/2] bna: Remove field bnad_dentry_files[] in struct bnad
    https://git.kernel.org/netdev/net-next/c/67826db318dd

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html