Skip to contentSkip to conversation

gpio: msic: Fix calculating register address in msic_gpio_to_oreg()

PATCH Applied Axel Lin 3 participants 3 messages Jul 24, 2012 – Aug 4, 2012 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: msic: Fix calculating register address in msic_gpio_to_oreg()

In the case offset is 20 ... 23, the equation to get the register should be:
INTEL_MSIC_GPIO1HV0CTLO - offset + 20

With above equation, we can get below mapping between offset and the register:
offset is 20: INTEL_MSIC_GPIO1HV0CTLO
offset is 21: INTEL_MSIC_GPIO1HV1CTLO
offset is 22: INTEL_MSIC_GPIO1HV2CTLO
offset is 23: INTEL_MSIC_GPIO1HV3CTLO

---
 drivers/gpio/gpio-msic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-msic.c +1 -1
index 71a838f..b389862 100644
@@ -99,7 +99,7 @@ static int msic_gpio_to_oreg(unsigned offset)
 	if (offset < 20)
 		return INTEL_MSIC_GPIO0HV0CTLO - offset + 16;
 
-	return INTEL_MSIC_GPIO1HV0CTLO + offset + 20;
+	return INTEL_MSIC_GPIO1HV0CTLO - offset + 20;
 }
 
 static int msic_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Axel Lin

In the case offset is 20 ... 23, the equation to get the register should be:
INTEL_MSIC_GPIO1HV0CTLO - offset + 20

With above equation, we can get below mapping between offset and the register:
offset is 20: INTEL_MSIC_GPIO1HV0CTLO
offset is 21: INTEL_MSIC_GPIO1HV1CTLO
offset is 22: INTEL_MSIC_GPIO1HV2CTLO
offset is 23: INTEL_MSIC_GPIO1HV3CTLO

---
  drivers/gpio/gpio-msic.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-msic.c +0 -0
index 71a838f..b389862 100644

drivers/gpio/gpio-msic.c static int msic_gpio_to_oreg(unsigned offset) · line 105

Quoted 8 lines
drivers/gpio/gpio-msic.c +1 -1
@@ -99,7 +99,7 @@ static int msic_gpio_to_oreg(unsigned offset)
  	if (offset<  20)
  		return INTEL_MSIC_GPIO0HV0CTLO - offset + 16;
 
-	return INTEL_MSIC_GPIO1HV0CTLO + offset + 20;
+	return INTEL_MSIC_GPIO1HV0CTLO - offset + 20;
  }
 
  static int msic_gpio_direction_input(struct gpio_chip *chip, unsigned offset)

Nice, good catch.

The last 4 of the 24 gpios will work properly as outputs with this fix.

#2 lore raw
In reply to Axel Lin
Quoted 10 lines · Axel Lin

In the case offset is 20 ... 23, the equation to get the register should be:
INTEL_MSIC_GPIO1HV0CTLO - offset + 20

With above equation, we can get below mapping between offset and the register:
offset is 20: INTEL_MSIC_GPIO1HV0CTLO
offset is 21: INTEL_MSIC_GPIO1HV1CTLO
offset is 22: INTEL_MSIC_GPIO1HV2CTLO
offset is 23: INTEL_MSIC_GPIO1HV3CTLO

Thanks, applied to my fixes branch with Mathias' ACK.

Yours,
Linus Walleij