The sm501_gpio_pin2nr() routine returns the wrong values for gpios in the
upper bank.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
static inline int sm501_gpio_pin2nr(struct sm501_devdata *sm, unsigned int pin)
{
struct sm501_gpio *gpio = &sm->gpio;
- return pin + (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base;
+ int base = (pin < 32) ? gpio->low.gpio.base : gpio->high.gpio.base;
+
+ return (pin % 32) + base;
}
static inline int sm501_gpio_isregistered(struct sm501_devdata *sm)