Skip to contentSkip to conversation

MFD: SM501 fix gpio number calculation for upper bank

PATCH New Ben Dooks 1 participant 1 message Jul 2, 2008 1 message not in the archive Multifunction devices (MFD)

lore
Share & tools
lore

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

Ben Dooks

author
#1 lore raw

PATCH 1/1 MFD: SM501 fix gpio number calculation for upper bank

The sm501_gpio_pin2nr() routine returns the wrong values for gpios in the upper bank.

drivers/mfd/sm501.c +3 -1
Index: linux-2.6.26-rc8-quilt3/drivers/mfd/sm501.c
===================================================================
@@ -1108,7 +1108,9 @@ static void sm501_gpio_remove(struct sm5
 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)