Skip to contentSkip to conversation

altera_pio: fix get_value

PATCH Superseded Julien Béraud 2 participants 2 messages Jan 5, 2019 GPIO

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 altera_pio: fix get_value

gpio_get_value should return 0 or 1, not 1 << pin

---
 drivers/gpio/altera_pio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/altera_pio.c +1 -1
index 59e30979f0..324f9c29a8 100644
@@ -56,7 +56,7 @@ static int altera_pio_get_value(struct udevice *dev, unsigned pin)
 	struct altera_pio_platdata *plat = dev_get_platdata(dev);
 	struct altera_pio_regs *const regs = plat->regs;
 
-	return readl(&regs->data) & (1 << pin);
+	return !!(readl(&regs->data) & (1 << pin));
 }
 
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 altera_pio: fix get_value

Quoted 1 line · Julien Béraud

gpio_get_value should return 0 or 1, not 1 << pin

It does not return 1 << pin, it returns value of the bit & (1 << pin). The patch is fine, reword the commit message and add my

Thanks

btw you can also align the $subject tags to "gpio: altera_pio: ...".

Quoted 19 lines
---
 drivers/gpio/altera_pio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/altera_pio.c +1 -1
index 59e30979f0..324f9c29a8 100644
@@ -56,7 +56,7 @@ static int altera_pio_get_value(struct udevice *dev, unsigned pin)
 	struct altera_pio_platdata *plat = dev_get_platdata(dev);
 	struct altera_pio_regs *const regs = plat->regs;
 
-	return readl(&regs->data) & (1 << pin);
+	return !!(readl(&regs->data) & (1 << pin));
 }
 
 
Signature · 2 lines
Best regards,
Marek Vasut