From bf8207ec8c3092555365036e28d227e997864799 Mon Sep 17 00:00:00 2001 From: Zhen Lei Date: Mon, 28 Oct 2024 10:09:42 +0800 Subject: [PATCH 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. Signed-off-by: Zhen Lei Reviewed-by: Simon Horman Link: https://patch.msgid.link/20241028020943.507-2-thunder.leizhen@huawei.com Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c index 97291bfbeea5..1a3a8bd13370 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c @@ -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; - } } } } From 67826db318dd6d105b60d4e380e97e36280b9681 Mon Sep 17 00:00:00 2001 From: Zhen Lei Date: Mon, 28 Oct 2024 10:09:43 +0800 Subject: [PATCH 2/2] bna: Remove field bnad_dentry_files[] in struct bnad 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. Signed-off-by: Zhen Lei Reviewed-by: Simon Horman Link: https://patch.msgid.link/20241028020943.507-3-thunder.leizhen@huawei.com Signed-off-by: Jakub Kicinski --- drivers/net/ethernet/brocade/bna/bnad.h | 1 - .../net/ethernet/brocade/bna/bnad_debugfs.c | 20 +++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h index 10b1e534030e..4396997c59d0 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.h +++ b/drivers/net/ethernet/brocade/bna/bnad.h @@ -351,7 +351,6 @@ struct bnad { /* debugfs specific data */ char *regdata; u32 reglen; - struct dentry *bnad_dentry_files[5]; struct dentry *port_debugfs_root; }; diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c index 1a3a8bd13370..8f0972e6737c 100644 --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c @@ -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);