Skip to content

Commit

Permalink
Input: adp5589-keys - fix adp5589_gpio_get_value()
Browse files Browse the repository at this point in the history
commit c684771 upstream.

The adp5589 seems to have the same behavior as similar devices as
explained in commit 910a9f5 ("Input: adp5588-keys - get value from
data out when dir is out").

Basically, when the gpio is set as output we need to get the value from
ADP5589_GPO_DATA_OUT_A register instead of ADP5589_GPI_STATUS_A.

Fixes: 9d2e173 ("Input: ADP5589 - new driver for I2C Keypad Decoder and I/O Expander")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20241001-b4-dev-adp5589-fw-conversion-v1-2-fca0149dfc47@analog.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
nunojsa authored and gregkh committed Oct 10, 2024
1 parent 7c3f042 commit 195e42c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/input/keyboard/adp5589-keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,17 @@ static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off)
struct adp5589_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = kpad->var->bank(kpad->gpiomap[off]);
unsigned int bit = kpad->var->bit(kpad->gpiomap[off]);
int val;

return !!(adp5589_read(kpad->client,
kpad->var->reg(ADP5589_GPI_STATUS_A) + bank) &
bit);
mutex_lock(&kpad->gpio_lock);
if (kpad->dir[bank] & bit)
val = kpad->dat_out[bank];
else
val = adp5589_read(kpad->client,
kpad->var->reg(ADP5589_GPI_STATUS_A) + bank);
mutex_unlock(&kpad->gpio_lock);

return !!(val & bit);
}

static void adp5589_gpio_set_value(struct gpio_chip *chip,
Expand Down

0 comments on commit 195e42c

Please sign in to comment.