]>
Commit | Line | Data |
---|---|---|
13835fac GKH |
1 | From c5bc6e526d3f217ed2cc3681d256dc4a2af4cc2b Mon Sep 17 00:00:00 2001 |
2 | From: Axel Lin <axel.lin@ingics.com> | |
3 | Date: Mon, 11 Mar 2019 21:29:37 +0800 | |
4 | Subject: gpio: adnp: Fix testing wrong value in adnp_gpio_direction_input | |
5 | ||
6 | From: Axel Lin <axel.lin@ingics.com> | |
7 | ||
8 | commit c5bc6e526d3f217ed2cc3681d256dc4a2af4cc2b upstream. | |
9 | ||
10 | Current code test wrong value so it does not verify if the written | |
11 | data is correctly read back. Fix it. | |
12 | Also make it return -EPERM if read value does not match written bit, | |
13 | just like it done for adnp_gpio_direction_output(). | |
14 | ||
15 | Fixes: 5e969a401a01 ("gpio: Add Avionic Design N-bit GPIO expander support") | |
16 | Cc: <stable@vger.kernel.org> | |
17 | Signed-off-by: Axel Lin <axel.lin@ingics.com> | |
18 | Reviewed-by: Thierry Reding <thierry.reding@gmail.com> | |
19 | Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> | |
20 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
21 | ||
22 | --- | |
23 | drivers/gpio/gpio-adnp.c | 6 ++++-- | |
24 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
25 | ||
26 | --- a/drivers/gpio/gpio-adnp.c | |
27 | +++ b/drivers/gpio/gpio-adnp.c | |
28 | @@ -132,8 +132,10 @@ static int adnp_gpio_direction_input(str | |
29 | if (err < 0) | |
30 | goto out; | |
31 | ||
32 | - if (err & BIT(pos)) | |
33 | - err = -EACCES; | |
34 | + if (value & BIT(pos)) { | |
35 | + err = -EPERM; | |
36 | + goto out; | |
37 | + } | |
38 | ||
39 | err = 0; | |
40 |