iio: core: no need to check return value of debugfs_create functions
PATCH 1/1 iio: core: no need to check return value of debugfs_create functions
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 Jonathan Cameron <[email protected]>
Cc Hartmut Knaack <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Peter Meerwald-Stadler <[email protected]>
Signed-off-by Greg Kroah-Hartman <[email protected]>
--- drivers/iio/industrialio-core.c | 35 ++++++++------------------------- 1 file changed, 8 insertions(+), 27 deletions(-)
drivers/iio/industrialio-core.c +8 -27
@@ -369,39 +369,25 @@ static void iio_device_unregister_debugfs(struct iio_dev *indio_dev) debugfs_remove_recursive(indio_dev->debugfs_dentry); } -static int iio_device_register_debugfs (struct iio_dev *indio_dev) +static void iio_device_register_debugfs (struct iio_dev *indio_dev) { -struct dentry *d; -if (indio_dev->info->debugfs_reg_access ==NULL ) -return 0 ; +return ;if (!iio_debugfs_dentry) -return 0 ; +return ; indio_dev->debugfs_dentry =debugfs_create_dir (dev_name (&indio_dev->dev), iio_debugfs_dentry); -if (indio_dev->debugfs_dentry ==NULL ) { -dev_warn (indio_dev->dev.parent, -"Failed to create debugfs directory\n" ); -return -EFAULT ; - } - - d =debugfs_create_file ("direct_reg_access" ,0644 , - indio_dev->debugfs_dentry, - indio_dev, &iio_debugfs_reg_fops); -if (!d) { -iio_device_unregister_debugfs (indio_dev); -return -ENOMEM ; - } -return 0 ; +debugfs_create_file ("direct_reg_access" ,0644 , + indio_dev->debugfs_dentry, indio_dev, + &iio_debugfs_reg_fops); }#else -static int iio_device_register_debugfs (struct iio_dev *indio_dev) +static void iio_device_register_debugfs (struct iio_dev *indio_dev) { -return 0 ; }static void iio_device_unregister_debugfs (struct iio_dev *indio_dev)
@@ -1672,12 +1658,7 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)/* configure elements for the chrdev */ indio_dev->dev.devt =MKDEV (MAJOR (iio_devt), indio_dev->id); - ret =iio_device_register_debugfs (indio_dev); -if (ret) { -dev_err (indio_dev->dev.parent, -"Failed to register debugfs interfaces\n" ); -return ret; - } +iio_device_register_debugfs (indio_dev); ret =iio_buffer_alloc_sysfs_and_mask (indio_dev);if (ret) {
Signature · 1 line
2.22.0
Jonathan Cameron
maintainerQuoted 10 lines · On Tue, 18 Jun 2019 17:54:40 +0200 Greg Kroah-Hartman…
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 Jonathan Cameron <[email protected]>Cc Hartmut Knaack <[email protected]>Cc Lars-Peter Clausen <[email protected]>Cc Peter Meerwald-Stadler <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke it a bit.
Thanks,
Jonathan
Quoted 69 lines
--- drivers/iio/industrialio-core.c | 35 ++++++++------------------------- 1 file changed, 8 insertions(+), 27 deletions(-)drivers/iio/industrialio-core.c +8
-27@@ -369,39 +369,25 @@ static void iio_device_unregister_debugfs(struct iio_dev *indio_dev) debugfs_remove_recursive(indio_dev->debugfs_dentry); } -static int iio_device_register_debugfs (struct iio_dev *indio_dev) +static void iio_device_register_debugfs (struct iio_dev *indio_dev) { -struct dentry *d; -if (indio_dev->info->debugfs_reg_access ==NULL ) -return 0 ; +return ;if (!iio_debugfs_dentry) -return 0 ; +return ; indio_dev->debugfs_dentry =debugfs_create_dir (dev_name (&indio_dev->dev), iio_debugfs_dentry); -if (indio_dev->debugfs_dentry ==NULL ) { -dev_warn (indio_dev->dev.parent, -"Failed to create debugfs directory\n" ); -return -EFAULT ; - } - - d =debugfs_create_file ("direct_reg_access" ,0644 , - indio_dev->debugfs_dentry, - indio_dev, &iio_debugfs_reg_fops); -if (!d) { -iio_device_unregister_debugfs (indio_dev); -return -ENOMEM ; - } -return 0 ; +debugfs_create_file ("direct_reg_access" ,0644 , + indio_dev->debugfs_dentry, indio_dev, + &iio_debugfs_reg_fops); }#else -static int iio_device_register_debugfs (struct iio_dev *indio_dev) +static void iio_device_register_debugfs (struct iio_dev *indio_dev) { -return 0 ; }static void iio_device_unregister_debugfs (struct iio_dev *indio_dev)@@ -1672,12 +1658,7 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)/* configure elements for the chrdev */ indio_dev->dev.devt =MKDEV (MAJOR (iio_devt), indio_dev->id); - ret =iio_device_register_debugfs (indio_dev); -if (ret) { -dev_err (indio_dev->dev.parent, -"Failed to register debugfs interfaces\n" ); -return ret; - } +iio_device_register_debugfs (indio_dev); ret =iio_buffer_alloc_sysfs_and_mask (indio_dev);if (ret) {