* [PATCH v2 0/2] bna: Remove error checking for debugfs create APIs
@ 2024-10-26 3:47 Zhen Lei
2024-10-26 3:47 ` [PATCH v2 1/2] " Zhen Lei
2024-10-26 3:48 ` [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad Zhen Lei
0 siblings, 2 replies; 6+ messages in thread
From: Zhen Lei @ 2024-10-26 3:47 UTC (permalink / raw)
To: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Zhen Lei
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 | 32 ++-----------------
2 files changed, 3 insertions(+), 30 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] bna: Remove error checking for debugfs create APIs
2024-10-26 3:47 [PATCH v2 0/2] bna: Remove error checking for debugfs create APIs Zhen Lei
@ 2024-10-26 3:47 ` Zhen Lei
2024-10-26 15:35 ` Simon Horman
2024-10-26 3:48 ` [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad Zhen Lei
1 sibling, 1 reply; 6+ messages in thread
From: Zhen Lei @ 2024-10-26 3:47 UTC (permalink / raw)
To: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: Zhen Lei
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 <thunder.leizhen@huawei.com>
---
drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 97291bfbeea589e..220d20a829c8a84 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -500,19 +500,12 @@ 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 */
snprintf(name, sizeof(name), "pci_dev:%s", pci_name(bnad->pcidev));
if (!bnad->port_debugfs_root) {
- bnad->port_debugfs_root =
- debugfs_create_dir(name, bna_debugfs_root);
-
+ bnad->port_debugfs_root = debugfs_create_dir(name, bna_debugfs_root);
atomic_inc(&bna_debugfs_port_count);
for (i = 0; i < ARRAY_SIZE(bnad_debugfs_files); i++) {
@@ -523,12 +516,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;
- }
}
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad
2024-10-26 3:47 [PATCH v2 0/2] bna: Remove error checking for debugfs create APIs Zhen Lei
2024-10-26 3:47 ` [PATCH v2 1/2] " Zhen Lei
@ 2024-10-26 3:48 ` Zhen Lei
2024-10-26 15:36 ` Simon Horman
1 sibling, 1 reply; 6+ messages in thread
From: Zhen Lei @ 2024-10-26 3:48 UTC (permalink / raw)
To: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, netdev
Cc: 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.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/net/ethernet/brocade/bna/bnad.h | 1 -
drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 17 ++---------------
2 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
index 10b1e534030e628..4396997c59d041f 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 220d20a829c8a84..7a27f9d1443bff2 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -510,12 +510,8 @@ 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);
}
}
}
@@ -524,15 +520,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);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] bna: Remove error checking for debugfs create APIs
2024-10-26 3:47 ` [PATCH v2 1/2] " Zhen Lei
@ 2024-10-26 15:35 ` Simon Horman
2024-10-28 1:56 ` Leizhen (ThunderTown)
0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2024-10-26 15:35 UTC (permalink / raw)
To: Zhen Lei
Cc: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
On Sat, Oct 26, 2024 at 11:47:59AM +0800, Zhen Lei wrote:
> 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 <thunder.leizhen@huawei.com>
> ---
> drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 15 +--------------
> 1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
> index 97291bfbeea589e..220d20a829c8a84 100644
> --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
> +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
> @@ -500,19 +500,12 @@ 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 */
> snprintf(name, sizeof(name), "pci_dev:%s", pci_name(bnad->pcidev));
> if (!bnad->port_debugfs_root) {
> - bnad->port_debugfs_root =
> - debugfs_create_dir(name, bna_debugfs_root);
> -
> + bnad->port_debugfs_root = debugfs_create_dir(name, bna_debugfs_root);
nit: This change seems to only change line wrapping from <= 80 columns wide
(still preferred for Networking code) to > 80 columns wide (not so good).
Probably this part of the patch should be removed.
If not, reworked so it is <= 80 columns wide.
Otherwise, this patch looks good to me.
> atomic_inc(&bna_debugfs_port_count);
>
> for (i = 0; i < ARRAY_SIZE(bnad_debugfs_files); i++) {
> @@ -523,12 +516,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;
> - }
> }
> }
> }
--
pw-bot: changes-requested
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad
2024-10-26 3:48 ` [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad Zhen Lei
@ 2024-10-26 15:36 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-10-26 15:36 UTC (permalink / raw)
To: Zhen Lei
Cc: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
On Sat, Oct 26, 2024 at 11:48:00AM +0800, Zhen Lei wrote:
> 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 <thunder.leizhen@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] bna: Remove error checking for debugfs create APIs
2024-10-26 15:35 ` Simon Horman
@ 2024-10-28 1:56 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 6+ messages in thread
From: Leizhen (ThunderTown) @ 2024-10-28 1:56 UTC (permalink / raw)
To: Simon Horman
Cc: Rasesh Mody, Sudarsana Kalluru, GR-Linux-NIC-Dev, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev
On 2024/10/26 23:35, Simon Horman wrote:
> On Sat, Oct 26, 2024 at 11:47:59AM +0800, Zhen Lei wrote:
>> 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 <thunder.leizhen@huawei.com>
>> ---
>> drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 15 +--------------
>> 1 file changed, 1 insertion(+), 14 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
>> index 97291bfbeea589e..220d20a829c8a84 100644
>> --- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
>> +++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
>> @@ -500,19 +500,12 @@ 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 */
>> snprintf(name, sizeof(name), "pci_dev:%s", pci_name(bnad->pcidev));
>> if (!bnad->port_debugfs_root) {
>> - bnad->port_debugfs_root =
>> - debugfs_create_dir(name, bna_debugfs_root);
>> -
>> + bnad->port_debugfs_root = debugfs_create_dir(name, bna_debugfs_root);
>
> nit: This change seems to only change line wrapping from <= 80 columns wide
> (still preferred for Networking code) to > 80 columns wide (not so good).
>
> Probably this part of the patch should be removed.
> If not, reworked so it is <= 80 columns wide.
Okay, I'll revert this one.
>
> Otherwise, this patch looks good to me.
then add: Reviewed-by: Simon Horman <horms@kernel.org>
>
>> atomic_inc(&bna_debugfs_port_count);
>>
>> for (i = 0; i < ARRAY_SIZE(bnad_debugfs_files); i++) {
>> @@ -523,12 +516,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;
>> - }
>> }
>> }
>> }
>
--
Regards,
Zhen Lei
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-28 1:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 3:47 [PATCH v2 0/2] bna: Remove error checking for debugfs create APIs Zhen Lei
2024-10-26 3:47 ` [PATCH v2 1/2] " Zhen Lei
2024-10-26 15:35 ` Simon Horman
2024-10-28 1:56 ` Leizhen (ThunderTown)
2024-10-26 3:48 ` [PATCH v2 2/2] bna: Remove field bnad_dentry_files[] in struct bnad Zhen Lei
2024-10-26 15:36 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).