diff mbox series

[v2] gpio: mockup: no need to check return value of debugfs_create functions

Message ID 20190620072519.GA21046@kroah.com
State New
Headers show
Series [v2] gpio: mockup: no need to check return value of debugfs_create functions | expand

Commit Message

Greg KH June 20, 2019, 7:25 a.m. UTC
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: Bamvor Jian Zhang <bamv2005@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2: fix build warning found by kbuild
    fix build error found by kbuild.  Did I even build this thing
    myself???

 drivers/gpio/gpio-mockup.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Bartosz Golaszewski June 24, 2019, 8:20 a.m. UTC | #1
czw., 20 cze 2019 o 09:25 Greg Kroah-Hartman
<gregkh@linuxfoundation.org> napisaƂ(a):
>
> 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: Bamvor Jian Zhang <bamv2005@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Cc: linux-gpio@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> v2: fix build warning found by kbuild
>     fix build error found by kbuild.  Did I even build this thing
>     myself???
>
>  drivers/gpio/gpio-mockup.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index b6a4efce7c92..135dac099d1e 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -315,7 +315,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
>                                       struct gpio_mockup_chip *chip)
>  {
>         struct gpio_mockup_dbgfs_private *priv;
> -       struct dentry *evfile;
>         struct gpio_chip *gc;
>         const char *devname;
>         char *name;
> @@ -325,32 +324,25 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
>         devname = dev_name(&gc->gpiodev->dev);
>
>         chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir);
> -       if (IS_ERR_OR_NULL(chip->dbg_dir))
> -               goto err;
>
>         for (i = 0; i < gc->ngpio; i++) {
>                 name = devm_kasprintf(dev, GFP_KERNEL, "%d", i);
>                 if (!name)
> -                       goto err;
> +                       return;
>
>                 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>                 if (!priv)
> -                       goto err;
> +                       return;
>
>                 priv->chip = chip;
>                 priv->offset = i;
>                 priv->desc = &gc->gpiodev->descs[i];
>
> -               evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv,
> -                                            &gpio_mockup_debugfs_ops);
> -               if (IS_ERR_OR_NULL(evfile))
> -                       goto err;
> +               debugfs_create_file(name, 0200, chip->dbg_dir, priv,
> +                                   &gpio_mockup_debugfs_ops);
>         }
>
>         return;
> -
> -err:
> -       dev_err(dev, "error creating debugfs files\n");
>  }
>
>  static int gpio_mockup_name_lines(struct device *dev,
> @@ -501,8 +493,6 @@ static int __init gpio_mockup_init(void)
>         }
>
>         gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL);
> -       if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir))
> -               gpio_mockup_err("error creating debugfs directory\n");
>
>         err = platform_driver_register(&gpio_mockup_driver);
>         if (err) {
> --
> 2.22.0
>

Shouldn't this patch also make the driver unconditionally call
gpio_mockup_debugfs_setup() at line 450?

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index b6a4efce7c92..135dac099d1e 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -315,7 +315,6 @@  static void gpio_mockup_debugfs_setup(struct device *dev,
 				      struct gpio_mockup_chip *chip)
 {
 	struct gpio_mockup_dbgfs_private *priv;
-	struct dentry *evfile;
 	struct gpio_chip *gc;
 	const char *devname;
 	char *name;
@@ -325,32 +324,25 @@  static void gpio_mockup_debugfs_setup(struct device *dev,
 	devname = dev_name(&gc->gpiodev->dev);
 
 	chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir);
-	if (IS_ERR_OR_NULL(chip->dbg_dir))
-		goto err;
 
 	for (i = 0; i < gc->ngpio; i++) {
 		name = devm_kasprintf(dev, GFP_KERNEL, "%d", i);
 		if (!name)
-			goto err;
+			return;
 
 		priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 		if (!priv)
-			goto err;
+			return;
 
 		priv->chip = chip;
 		priv->offset = i;
 		priv->desc = &gc->gpiodev->descs[i];
 
-		evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv,
-					     &gpio_mockup_debugfs_ops);
-		if (IS_ERR_OR_NULL(evfile))
-			goto err;
+		debugfs_create_file(name, 0200, chip->dbg_dir, priv,
+				    &gpio_mockup_debugfs_ops);
 	}
 
 	return;
-
-err:
-	dev_err(dev, "error creating debugfs files\n");
 }
 
 static int gpio_mockup_name_lines(struct device *dev,
@@ -501,8 +493,6 @@  static int __init gpio_mockup_init(void)
 	}
 
 	gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL);
-	if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir))
-		gpio_mockup_err("error creating debugfs directory\n");
 
 	err = platform_driver_register(&gpio_mockup_driver);
 	if (err) {