mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] gpio: get function returns masked register value
@ 2020-07-24 11:09 Renaud Barbier
  2020-08-03 19:20 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Renaud Barbier @ 2020-07-24 11:09 UTC (permalink / raw)
  To: barebox; +Cc: Renaud Barbier

Unlike Linux the generic driver get function returns the masked register
content and not the 0 or 1 value. The consequence is that gpio_get_value
returns for instance 0x10 for bit 4 instead of 1.
Use the Linux normalized form instead.

Signed-off-by: Renaud Barbier <renaud.barbier@abaco.com>
---
 drivers/gpio/gpio-generic.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index e4c4f39..2e0dad9 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -62,7 +62,7 @@ static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
 	struct bgpio_chip *bgc = to_bgpio_chip(gc);
 
-	return bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio);
+	return !!(bgc->read_reg(bgc->reg_dat) & bgc->pin2mask(bgc, gpio));
 }
 
 static void bgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] gpio: get function returns masked register value
  2020-07-24 11:09 [PATCH] gpio: get function returns masked register value Renaud Barbier
@ 2020-08-03 19:20 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-08-03 19:20 UTC (permalink / raw)
  To: Renaud Barbier; +Cc: barebox

On Fri, Jul 24, 2020 at 12:09:37PM +0100, Renaud Barbier wrote:
> Unlike Linux the generic driver get function returns the masked register
> content and not the 0 or 1 value. The consequence is that gpio_get_value
> returns for instance 0x10 for bit 4 instead of 1.
> Use the Linux normalized form instead.
> 
> Signed-off-by: Renaud Barbier <renaud.barbier@abaco.com>
> ---
>  drivers/gpio/gpio-generic.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied to master, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-08-03 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 11:09 [PATCH] gpio: get function returns masked register value Renaud Barbier
2020-08-03 19:20 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox