Skip to content

Commit

Permalink
mei: no need to check return value of debugfs_create functions
Browse files Browse the repository at this point in the history
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Greg Kroah-Hartman committed Jun 18, 2019
1 parent d7ef485 commit 5666d89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 48 deletions.
47 changes: 11 additions & 36 deletions drivers/misc/mei/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,47 +233,22 @@ void mei_dbgfs_deregister(struct mei_device *dev)
*
* @dev: the mei device structure
* @name: the mei device name
*
* Return: 0 on success, <0 on failure.
*/
int mei_dbgfs_register(struct mei_device *dev, const char *name)
void mei_dbgfs_register(struct mei_device *dev, const char *name)
{
struct dentry *dir, *f;
struct dentry *dir;

dir = debugfs_create_dir(name, NULL);
if (!dir)
return -ENOMEM;

dev->dbgfs_dir = dir;

f = debugfs_create_file("meclients", S_IRUSR, dir,
dev, &mei_dbgfs_fops_meclients);
if (!f) {
dev_err(dev->dev, "meclients: registration failed\n");
goto err;
}
f = debugfs_create_file("active", S_IRUSR, dir,
dev, &mei_dbgfs_fops_active);
if (!f) {
dev_err(dev->dev, "active: registration failed\n");
goto err;
}
f = debugfs_create_file("devstate", S_IRUSR, dir,
dev, &mei_dbgfs_fops_devstate);
if (!f) {
dev_err(dev->dev, "devstate: registration failed\n");
goto err;
}
f = debugfs_create_file("allow_fixed_address", S_IRUSR | S_IWUSR, dir,
&dev->allow_fixed_address,
&mei_dbgfs_fops_allow_fa);
if (!f) {
dev_err(dev->dev, "allow_fixed_address: registration failed\n");
goto err;
}
return 0;
err:
mei_dbgfs_deregister(dev);
return -ENODEV;
debugfs_create_file("meclients", S_IRUSR, dir, dev,
&mei_dbgfs_fops_meclients);
debugfs_create_file("active", S_IRUSR, dir, dev,
&mei_dbgfs_fops_active);
debugfs_create_file("devstate", S_IRUSR, dir, dev,
&mei_dbgfs_fops_devstate);
debugfs_create_file("allow_fixed_address", S_IRUSR | S_IWUSR, dir,
&dev->allow_fixed_address,
&mei_dbgfs_fops_allow_fa);
}

8 changes: 1 addition & 7 deletions drivers/misc/mei/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,16 +984,10 @@ int mei_register(struct mei_device *dev, struct device *parent)
goto err_dev_create;
}

ret = mei_dbgfs_register(dev, dev_name(clsdev));
if (ret) {
dev_err(clsdev, "cannot register debugfs ret = %d\n", ret);
goto err_dev_dbgfs;
}
mei_dbgfs_register(dev, dev_name(clsdev));

return 0;

err_dev_dbgfs:
device_destroy(mei_class, devno);
err_dev_create:
cdev_del(&dev->cdev);
err_dev_add:
Expand Down
7 changes: 2 additions & 5 deletions drivers/misc/mei/mei_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,10 @@ bool mei_hbuf_acquire(struct mei_device *dev);
bool mei_write_is_idle(struct mei_device *dev);

#if IS_ENABLED(CONFIG_DEBUG_FS)
int mei_dbgfs_register(struct mei_device *dev, const char *name);
void mei_dbgfs_register(struct mei_device *dev, const char *name);
void mei_dbgfs_deregister(struct mei_device *dev);
#else
static inline int mei_dbgfs_register(struct mei_device *dev, const char *name)
{
return 0;
}
static inline void mei_dbgfs_register(struct mei_device *dev, const char *name) {}
static inline void mei_dbgfs_deregister(struct mei_device *dev) {}
#endif /* CONFIG_DEBUG_FS */

Expand Down

0 comments on commit 5666d89

Please sign in to comment.