]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input
authorAxel Lin <axel.lin@ingics.com>
Mon, 11 Mar 2019 13:29:37 +0000 (21:29 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838116
commit c5bc6e526d3f217ed2cc3681d256dc4a2af4cc2b upstream.

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")
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/gpio/gpio-adnp.c

index 44c09904daa6adcbd261333986e4c09fbb627fc0..2ac3b96d7c953541db670ef83a86fe12c810ecd0 100644 (file)
@@ -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;