Skip to content

Commit

Permalink
gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input
Browse files Browse the repository at this point in the history
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: 5e969a4 ("gpio: Add Avionic Design N-bit GPIO expander support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
  • Loading branch information
Axel Lin authored and Bartosz Golaszewski committed Mar 22, 2019
1 parent 7ecced0 commit c5bc6e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/gpio/gpio-adnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit c5bc6e5

Please sign in to comment.