* [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file
@ 2023-05-30 15:42 Osama Muhammad
2023-05-31 6:35 ` David Rheinsberg
2023-08-14 9:15 ` Jiri Kosina
0 siblings, 2 replies; 3+ messages in thread
From: Osama Muhammad @ 2023-05-30 15:42 UTC (permalink / raw)
To: david.rheinsberg, jikos, benjamin.tissoires
Cc: linux-input, linux-kernel, Osama Muhammad
This patch removes the error checking for debugfs_create_file
in hid-wiimote-debug.c.c. This is because the debugfs_create_file()
does not return NULL but an ERR_PTR after an error.
The DebugFS kernel API is developed in a way that the
caller can safely ignore the errors that occur during
the creation of DebugFS nodes.The debugfs Api handles
it gracefully. The check is unnecessary.
Link to the comment above debugfs_create_file:
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451
Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
changes since v1
-In v1 the IS_ERR was used for error checking which is dropped now.
---
drivers/hid/hid-wiimote-debug.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index a99dcca2e099..00f9be55f148 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -173,7 +173,6 @@ int wiidebug_init(struct wiimote_data *wdata)
{
struct wiimote_debug *dbg;
unsigned long flags;
- int ret = -ENOMEM;
dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
if (!dbg)
@@ -183,13 +182,9 @@ int wiidebug_init(struct wiimote_data *wdata)
dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
- if (!dbg->eeprom)
- goto err;
dbg->drm = debugfs_create_file("drm", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
- if (!dbg->drm)
- goto err_drm;
spin_lock_irqsave(&wdata->state.lock, flags);
wdata->debug = dbg;
@@ -197,11 +192,6 @@ int wiidebug_init(struct wiimote_data *wdata)
return 0;
-err_drm:
- debugfs_remove(dbg->eeprom);
-err:
- kfree(dbg);
- return ret;
}
void wiidebug_deinit(struct wiimote_data *wdata)
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file
2023-05-30 15:42 [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file Osama Muhammad
@ 2023-05-31 6:35 ` David Rheinsberg
2023-08-14 9:15 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: David Rheinsberg @ 2023-05-31 6:35 UTC (permalink / raw)
To: Osama Muhammad; +Cc: jikos, benjamin.tissoires, linux-input, linux-kernel
Hi
On Tue, 30 May 2023 at 17:43, Osama Muhammad <osmtendev@gmail.com> wrote:
>
> This patch removes the error checking for debugfs_create_file
> in hid-wiimote-debug.c.c. This is because the debugfs_create_file()
> does not return NULL but an ERR_PTR after an error.
> The DebugFS kernel API is developed in a way that the
> caller can safely ignore the errors that occur during
> the creation of DebugFS nodes.The debugfs Api handles
> it gracefully. The check is unnecessary.
>
> Link to the comment above debugfs_create_file:
> https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451
>
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
Looks good, thanks!
Reviewed-by: David Rheinsberg <david@readahead.eu>
Thanks
David
> ---
> changes since v1
> -In v1 the IS_ERR was used for error checking which is dropped now.
> ---
> drivers/hid/hid-wiimote-debug.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
> index a99dcca2e099..00f9be55f148 100644
> --- a/drivers/hid/hid-wiimote-debug.c
> +++ b/drivers/hid/hid-wiimote-debug.c
> @@ -173,7 +173,6 @@ int wiidebug_init(struct wiimote_data *wdata)
> {
> struct wiimote_debug *dbg;
> unsigned long flags;
> - int ret = -ENOMEM;
>
> dbg = kzalloc(sizeof(*dbg), GFP_KERNEL);
> if (!dbg)
> @@ -183,13 +182,9 @@ int wiidebug_init(struct wiimote_data *wdata)
>
> dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
> dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
> - if (!dbg->eeprom)
> - goto err;
>
> dbg->drm = debugfs_create_file("drm", S_IRUSR,
> dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
> - if (!dbg->drm)
> - goto err_drm;
>
> spin_lock_irqsave(&wdata->state.lock, flags);
> wdata->debug = dbg;
> @@ -197,11 +192,6 @@ int wiidebug_init(struct wiimote_data *wdata)
>
> return 0;
>
> -err_drm:
> - debugfs_remove(dbg->eeprom);
> -err:
> - kfree(dbg);
> - return ret;
> }
>
> void wiidebug_deinit(struct wiimote_data *wdata)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file
2023-05-30 15:42 [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file Osama Muhammad
2023-05-31 6:35 ` David Rheinsberg
@ 2023-08-14 9:15 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2023-08-14 9:15 UTC (permalink / raw)
To: Osama Muhammad
Cc: david.rheinsberg, benjamin.tissoires, linux-input, linux-kernel
On Tue, 30 May 2023, Osama Muhammad wrote:
> This patch removes the error checking for debugfs_create_file
> in hid-wiimote-debug.c.c. This is because the debugfs_create_file()
> does not return NULL but an ERR_PTR after an error.
> The DebugFS kernel API is developed in a way that the
> caller can safely ignore the errors that occur during
> the creation of DebugFS nodes.The debugfs Api handles
> it gracefully. The check is unnecessary.
>
> Link to the comment above debugfs_create_file:
> https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451
>
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
>
> ---
> changes since v1
> -In v1 the IS_ERR was used for error checking which is dropped now.
Now applied, sorry for the delay.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-14 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 15:42 [PATCH v2] hid-wiimote-debug.c: Drop error checking for debugfs_create_file Osama Muhammad
2023-05-31 6:35 ` David Rheinsberg
2023-08-14 9:15 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox