diff mbox series

[v3] gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input

Message ID 20190311132937.6828-1-axel.lin@ingics.com
State New
Headers show
Series [v3] gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input | expand

Commit Message

Axel Lin March 11, 2019, 1:29 p.m. UTC
Current code test wrong value so it does not verify if the written
data is correctly read back. Fix it.
Also make it return -EPERM if read value does not match written bit,
just like it done for adnp_gpio_direction_output().

Fixes: 5e969a401a01 ("gpio: Add Avionic Design N-bit GPIO expander support")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Thierry Reding <thierry.reding@gmail.com>
---
v3: Add fixes tag
v2: Address Thierry's comment:
Also make it return -EPERM if read value does not match written bit,
just like it done for adnp_gpio_direction_output().

 drivers/gpio/gpio-adnp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Bartosz Golaszewski March 11, 2019, 1:36 p.m. UTC | #1
pon., 11 mar 2019 o 14:29 Axel Lin <axel.lin@ingics.com> napisaƂ(a):
>
> Current code test wrong value so it does not verify if the written
> data is correctly read back. Fix it.
> Also make it return -EPERM if read value does not match written bit,
> just like it done for adnp_gpio_direction_output().
>
> Fixes: 5e969a401a01 ("gpio: Add Avionic Design N-bit GPIO expander support")
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> Reviewed-by: Thierry Reding <thierry.reding@gmail.com>
> ---
> v3: Add fixes tag
> v2: Address Thierry's comment:
> Also make it return -EPERM if read value does not match written bit,
> just like it done for adnp_gpio_direction_output().
>
>  drivers/gpio/gpio-adnp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
> index 91b90c0cea73..12acdac85820 100644
> --- a/drivers/gpio/gpio-adnp.c
> +++ b/drivers/gpio/gpio-adnp.c
> @@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
>         if (err < 0)
>                 goto out;
>
> -       if (err & BIT(pos))
> -               err = -EACCES;
> +       if (value & BIT(pos)) {
> +               err = -EPERM;
> +               goto out;
> +       }
>
>         err = 0;
>
> --
> 2.17.1
>

Applied to for-current. I'll send it to Linus W after v5.1-rc1 is tagged.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index 91b90c0cea73..12acdac85820 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -132,8 +132,10 @@  static int adnp_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 	if (err < 0)
 		goto out;
 
-	if (err & BIT(pos))
-		err = -EACCES;
+	if (value & BIT(pos)) {
+		err = -EPERM;
+		goto out;
+	}
 
 	err = 0;