Skip to contentSkip to conversation

GPIO: gpio-pxa: fix bug when get gpio value

PATCH In review Neil Zhang 3 participants 4 messages Sep 26, 2012 – Sep 30, 2012

Subsystems (2)
lore
Share & tools
lore

Neil Zhang

author
#0 lore raw

PATCH v2 1/1 GPIO: gpio-pxa: fix bug when get gpio value

We need to return 0 or 1 when get gpio value.

---
 drivers/gpio/gpio-pxa.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpio/gpio-pxa.c +3 -1
index 9cac88a..3c9dc8c 100644
@@ -269,7 +269,9 @@ 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)) ? 1 : 0;
 }
 
 static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 23 lines · Neil Zhang

We need to return 0 or 1 when get gpio value.

---
 drivers/gpio/gpio-pxa.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpio/gpio-pxa.c +3 -2
index 9cac88a..3c9dc8c 100644
@@ -269,7 +269,9 @@ 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)) ? 1 : 0;
 }
 
 static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
--
Quoted 2 lines

1.7.4.1

gpio_get_value() is used to dump bits from GPLR register in mach-pxa directory. Unless you update those code at the same time, this patch can't be merged.

Regards
Haojian

author
#2 lore raw
Quoted 34 lines

-----Original Message-----
From: Haojian Zhuang [mailto:[email protected]]
Sent: 2012年9月26日 14:44
To: Neil Zhang
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH V2] GPIO: gpio-pxa: fix bug when get gpio value

drivers/gpio/gpio-pxa.c static int pxa_gpio_direction_output(struct gpio_chip

Quoted 12 lines · Neil Zhang

We need to return 0 or 1 when get gpio value.

---
 drivers/gpio/gpio-pxa.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/gpio/gpio-pxa.c +0 -0
index 9cac88a..3c9dc8c 100644
@@ -269,7 +269,9 @@ static int pxa_gpio_direction_output(struct gpio_chip

*chip,

drivers/gpio/gpio-pxa.c static int pxa_gpio_direction_output(struct gpio_chip *chip,

Quoted 4 lines
drivers/gpio/gpio-pxa.c +0 -1
 static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
-       return readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET) & (1 <<

offset);

drivers/gpio/gpio-pxa.c static int pxa_gpio_direction_output(struct gpio_chip *chip,

Quoted 6 lines
drivers/gpio/gpio-pxa.c +3 -0
+       u32 gplr = readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET);
+
+       return (gplr & (1 << offset)) ? 1 : 0;
 }
 
 static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int
Quoted 9 lines

value)

Quoted 3 lines
drivers/gpio/gpio-pxa.c +0 -1
--

1.7.4.1

gpio_get_value() is used to dump bits from GPLR register in mach-pxa directory.
Unless you update those code at the same time, this patch can't be merged.

It's a big change, I will do it when I have time.

Quoted 2 lines

Regards
Haojian

Best Regards,
Neil Zhang �翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{炳G珴�妠ay�蕠跈�,jf"穐殢飦�戧鐉_璁(殠娸"濟�m���G珴�⒏?櫒璀�&x忈秈O曟瑉窔v豝�m��� �鹅�⒏?朓�

#3 lore raw
In reply to Neil Zhang
Quoted 3 lines · Neil Zhang

We need to return 0 or 1 when get gpio value.

Aha there is another patch fixing that comment I had, sorry, going through the mail backlog.

But you need to take Haojian's comments into account so I'm not applying it right now.

Yours,
Linus Walleij