linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: pxa: fix bug when get gpio value
@ 2014-01-09  9:25 Neil Zhang
  2014-01-09  9:32 ` Neil Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Neil Zhang @ 2014-01-09  9:25 UTC (permalink / raw)
  To: linus.walleij, gnurou, linux-gpio, linux-kernel; +Cc: Neil Zhang

gpio_get_value should return 0 or 1.

I have checked mach-mmp / mach-pxa / plat-pxa / plat-orion / mach-orion5x.
It's OK for all of them to change this function to return 0 and 1.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
---
 drivers/gpio/gpio-pxa.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index cc13d1b..42e6e64 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -263,7 +263,8 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
 
 static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-	return readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET) & (1 << offset);
+	u32 gplr = readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET);
+	return !!(gplr & (1 << offset));
 }
 
 static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-15  7:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09  9:25 [PATCH] gpio: pxa: fix bug when get gpio value Neil Zhang
2014-01-09  9:32 ` Neil Zhang
2014-01-09 10:46 ` Gerhard Sittig
2014-01-10  2:04   ` Neil Zhang
2014-01-15  7:55   ` Linus Walleij
2014-01-15  7:48 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).