Skip to content

Commit

Permalink
HID: hid-wiimote-debug.c: Drop error checking for debugfs_create_file
Browse files Browse the repository at this point in the history
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>
Reviewed-by: David Rheinsberg <david@readahead.eu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Osama Muhammad authored and Jiri Kosina committed Aug 14, 2023
1 parent 1d75460 commit 9620a78
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions drivers/hid/hid-wiimote-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -183,25 +182,16 @@ 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;
spin_unlock_irqrestore(&wdata->state.lock, flags);

return 0;

err_drm:
debugfs_remove(dbg->eeprom);
err:
kfree(dbg);
return ret;
}

void wiidebug_deinit(struct wiimote_data *wdata)
Expand Down

0 comments on commit 9620a78

Please sign in to comment.