Skip to contentSkip to conversation

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

PATCH Gregory CLEMENT 3 participants 3 messages Aug 12, 2013 – Aug 16, 2013 1 message not in the archive GPIO

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Gregory CLEMENT

author Reviewed-by
#1 lore raw
Quoted 7 lines · Andrew Ruder

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.

Good catch. I forgot this one and as on my board I wasn't able to test the input I didn't noticed it.
Thanks

Quoted 21 lines

---

 drivers/gpio/gpio-pca953x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pca953x.c +1 -1
index 426c51d..1a7ab13 100644
@@ -308,7 +308,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off)
 		return 0;
 	}
 
-	return (reg_val & (1u << off)) ? 1 : 0;
+	return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0;
 }
 
 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw
Quoted 5 lines · Gregory CLEMENT

Good catch. I forgot this one and as on my board I wasn't able to test the input I didn't noticed it.
Thanks

Linus,

Any chance you can take this one into your tree?

Thanks,
Andy

#3 lore raw
In reply to a message not in the archive
Quoted 9 lines · Andrew Ruder

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.

Patch applied with Gregory's ACK.

Yours,
Linus Walleij