diff options
| author | Linus Walleij <[email protected]> | 2015-12-10 14:55:29 +0000 |
|---|---|---|
| committer | Linus Walleij <[email protected]> | 2015-12-17 14:47:38 +0000 |
| commit | 67a76aafec00db46fbd65d7d17a1cde1adde70c5 (patch) | |
| tree | 0f1373bf6ffc834c42738d80d79db00616f599ea /drivers/gpio/gpio-generic.c | |
| parent | gpio: ath79: Fix the logic to clear offset bit of AR71XX_GPIO_REG_OE register (diff) | |
| download | kernel-67a76aafec00db46fbd65d7d17a1cde1adde70c5.tar.gz kernel-67a76aafec00db46fbd65d7d17a1cde1adde70c5.zip | |
gpio: generic: clamp values from bgpio_get_set()
The bgpio_get_set() call should return a value clamped to [0,1],
the current code will return a negative value if reading
bit 31, which turns the value negative as this is a signed value
and thus gets interpreted as an error by the gpiolib core.
Found on the gpio-mxc but applies to any MMIO driver.
Cc: [email protected] # 4.3+
Cc: [email protected]
Cc: Vladimir Zapolskiy <[email protected]>
Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()")
Reported-by: Clemens Gruber <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Diffstat (limited to 'drivers/gpio/gpio-generic.c')
| -rw-r--r-- | drivers/gpio/gpio-generic.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index bd5193c67a9c..88ae70ddb127 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -141,9 +141,9 @@ static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) unsigned long pinmask = bgc->pin2mask(bgc, gpio); if (bgc->dir & pinmask) - return bgc->read_reg(bgc->reg_set) & pinmask; + return !!(bgc->read_reg(bgc->reg_set) & pinmask); else - return bgc->read_reg(bgc->reg_dat) & pinmask; + return !!(bgc->read_reg(bgc->reg_dat) & pinmask); } static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) |
