mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-01 08:20:44 -05:00
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: e20538b82f ("gpio: Propagate errors from chip->get()")
Reported-by: Clemens Gruber <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
This commit is contained in:
parent
3a57e74162
commit
67a76aafec
1 changed files with 2 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue