LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] gpio: pca953x: do not ignore i2c errors
@ 2021-09-23 17:22 Nikita Yushchenko
  2021-09-29 18:41 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Nikita Yushchenko @ 2021-09-23 17:22 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, Andrey Gusakov, Nikita Yushchenko

From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>

Per gpio_chip interface, error shall be proparated to the caller.

Attempt to silent diagnostics by returning zero (as written in the
comment) is plain wrong, because the zero return can be interpreted by
the caller as the gpio value.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
 drivers/gpio/gpio-pca953x.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index f5cfc0698799..8ebf369b3ba0 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -468,15 +468,8 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
 	mutex_lock(&chip->i2c_lock);
 	ret = regmap_read(chip->regmap, inreg, &reg_val);
 	mutex_unlock(&chip->i2c_lock);
-	if (ret < 0) {
-		/*
-		 * NOTE:
-		 * diagnostic already emitted; that's all we should
-		 * do unless gpio_*_value_cansleep() calls become different
-		 * from their nonsleeping siblings (and report faults).
-		 */
-		return 0;
-	}
+	if (ret < 0)
+		return ret;
 
 	return !!(reg_val & bit);
 }
-- 
2.30.2


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

* Re: [PATCH] gpio: pca953x: do not ignore i2c errors
  2021-09-23 17:22 [PATCH] gpio: pca953x: do not ignore i2c errors Nikita Yushchenko
@ 2021-09-29 18:41 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2021-09-29 18:41 UTC (permalink / raw)
  To: Nikita Yushchenko; +Cc: Linus Walleij, linux-gpio, LKML, Andrey Gusakov

On Thu, Sep 23, 2021 at 7:22 PM Nikita Yushchenko
<nikita.yoush@cogentembedded.com> wrote:
>
> From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
>
> Per gpio_chip interface, error shall be proparated to the caller.
>
> Attempt to silent diagnostics by returning zero (as written in the
> comment) is plain wrong, because the zero return can be interpreted by
> the caller as the gpio value.
>
> Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index f5cfc0698799..8ebf369b3ba0 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -468,15 +468,8 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
>         mutex_lock(&chip->i2c_lock);
>         ret = regmap_read(chip->regmap, inreg, &reg_val);
>         mutex_unlock(&chip->i2c_lock);
> -       if (ret < 0) {
> -               /*
> -                * NOTE:
> -                * diagnostic already emitted; that's all we should
> -                * do unless gpio_*_value_cansleep() calls become different
> -                * from their nonsleeping siblings (and report faults).
> -                */
> -               return 0;
> -       }
> +       if (ret < 0)
> +               return ret;
>
>         return !!(reg_val & bit);
>  }
> --
> 2.30.2
>

Applied, thanks!

Bart

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

end of thread, other threads:[~2021-09-29 18:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 17:22 [PATCH] gpio: pca953x: do not ignore i2c errors Nikita Yushchenko
2021-09-29 18:41 ` Bartosz Golaszewski

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).