Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: pca953x: fix gpio input on gpio offsets >= 8

This change fixes a regression introduced by commit
f5f0b7aa8 (gpio: pca953x: make the register access by GPIO bank)

When the pca953x driver was converted to using 8-bit reads/writes
the bitmask in pca953x_gpio_get_value wasn't adjusted with a
modulus BANK_SZ and consequently looks at the wrong bits in the
input register.

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andrew Ruder and committed by
Linus Walleij
40a625da 08a67a58

+1 -1
+1 -1
drivers/gpio/gpio-pca953x.c
··· 308 308 return 0; 309 309 } 310 310 311 - return (reg_val & (1u << off)) ? 1 : 0; 311 + return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0; 312 312 } 313 313 314 314 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)