linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions
@ 2019-06-26  8:45 Bartosz Golaszewski
  2019-06-26 11:54 ` Linus Walleij
  2019-06-26 12:22 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-06-26  8:45 UTC (permalink / raw)
  To: Linus Walleij, Greg Kroah-Hartman
  Cc: linux-gpio, linux-kernel, Bamvor Jian Zhang, Bartosz Golaszewski

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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>
[Bartosz: removed one more check for debugfs return value]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
v1 -> v2:
- fix build warning found by kbuild
- fix build error found by kbuild

v2 -> v3:
- remove one more unnecessary ifdef

 drivers/gpio/gpio-mockup.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index b6a4efce7c92..f1a9c0544e3f 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,
@@ -447,8 +439,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 	if (rv)
 		return rv;
 
-	if (!IS_ERR_OR_NULL(gpio_mockup_dbg_dir))
-		gpio_mockup_debugfs_setup(dev, chip);
+	gpio_mockup_debugfs_setup(dev, chip);
 
 	return 0;
 }
@@ -501,8 +492,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.21.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions
  2019-06-26  8:45 [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions Bartosz Golaszewski
@ 2019-06-26 11:54 ` Linus Walleij
  2019-06-26 11:55   ` Bartosz Golaszewski
  2019-06-26 12:22 ` Greg Kroah-Hartman
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2019-06-26 11:54 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Greg Kroah-Hartman, open list:GPIO SUBSYSTEM, linux-kernel,
	Bamvor Jian Zhang, Bartosz Golaszewski

On Wed, Jun 26, 2019 at 10:46 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> 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>
> [Bartosz: removed one more check for debugfs return value]
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
> v1 -> v2:
> - fix build warning found by kbuild
> - fix build error found by kbuild
>
> v2 -> v3:
> - remove one more unnecessary ifdef

Looks good
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Will you send me this in a pull request with the rest of
the stuff you have queued?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions
  2019-06-26 11:54 ` Linus Walleij
@ 2019-06-26 11:55   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2019-06-26 11:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Greg Kroah-Hartman, open list:GPIO SUBSYSTEM, linux-kernel,
	Bamvor Jian Zhang, Bartosz Golaszewski

śr., 26 cze 2019 o 13:54 Linus Walleij <linus.walleij@linaro.org> napisał(a):
>
> On Wed, Jun 26, 2019 at 10:46 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >
> > 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>
> > [Bartosz: removed one more check for debugfs return value]
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
> > v1 -> v2:
> > - fix build warning found by kbuild
> > - fix build error found by kbuild
> >
> > v2 -> v3:
> > - remove one more unnecessary ifdef
>
> Looks good
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> Will you send me this in a pull request with the rest of
> the stuff you have queued?
>
> Yours,
> Linus Walleij

Yes, I'll do it shortly.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions
  2019-06-26  8:45 [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions Bartosz Golaszewski
  2019-06-26 11:54 ` Linus Walleij
@ 2019-06-26 12:22 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-26 12:22 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, linux-gpio, linux-kernel, Bamvor Jian Zhang,
	Bartosz Golaszewski

On Wed, Jun 26, 2019 at 10:45:57AM +0200, Bartosz Golaszewski wrote:
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> 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>
> [Bartosz: removed one more check for debugfs return value]

THank you for making this change.  I'm on the road all this week and
have had very limited time for email and doing any work like this.

Your change looks good to me!

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-26 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26  8:45 [PATCH v3] gpio: mockup: no need to check return value of debugfs_create functions Bartosz Golaszewski
2019-06-26 11:54 ` Linus Walleij
2019-06-26 11:55   ` Bartosz Golaszewski
2019-06-26 12:22 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).