summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenaud Barbier <renaud.barbier@abaco.com>2020-07-24 12:09:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-08-03 21:20:18 +0200
commitf9e7a605a8e1e6db11f62f2a9335c3775b44b220 (patch)
tree6fb10ea6e42c25c9db8588696120c19f33daac5a
parentc667f8cc98a162ab5b10663fabf80821a69588f5 (diff)
downloadbarebox-f9e7a605a8e1e6db11f62f2a9335c3775b44b220.tar.gz
barebox-f9e7a605a8e1e6db11f62f2a9335c3775b44b220.tar.xz
gpio: get function returns masked register value
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/gpio/gpio-generic.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index e4c4f39b6..2e0dad997 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)