Skip to content

Commit 992196f

Browse files
jeff-dagenaislinusw
authored andcommitted
gpio: adp5588: get value from data out when dir is out
As discussed here: http://ez.analog.com/message/35852, the 5587 revC and 5588 revB spec sheets contain a mistake in the GPIO_DAT_STATx register description. According to R.Shnell at ADI, as well as my own observations, it should read: "GPIO data status (shows GPIO state when read for inputs)". This commit changes the get value function accordingly. Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 390d82e commit 992196f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/gpio/gpio-adp5588.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,20 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off)
6767
{
6868
struct adp5588_gpio *dev =
6969
container_of(chip, struct adp5588_gpio, gpio_chip);
70+
unsigned bank = ADP5588_BANK(off);
71+
unsigned bit = ADP5588_BIT(off);
72+
int val;
7073

71-
return !!(adp5588_gpio_read(dev->client,
72-
GPIO_DAT_STAT1 + ADP5588_BANK(off)) & ADP5588_BIT(off));
74+
mutex_lock(&dev->lock);
75+
76+
if (dev->dir[bank] & bit)
77+
val = dev->dat_out[bank];
78+
else
79+
val = adp5588_gpio_read(dev->client, GPIO_DAT_STAT1 + bank);
80+
81+
mutex_unlock(&dev->lock);
82+
83+
return !!(val & bit);
7384
}
7485

7586
static void adp5588_gpio_set_value(struct gpio_chip *chip,

0 commit comments

Comments
 (0)