mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
gpio: generic: clamp retured value to [0,1]
The generic GPIO would return 0 for low generic GPIO, and something != 0 for high GPIO. Let's make this sane by clamping the returned value to [0,1]. Reported-by: Evgeny Boger <boger@contactless.ru> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
f86b7c70bc
commit
25b35da7f4
1 changed files with 1 additions and 1 deletions
|
@ -139,7 +139,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)
|
||||
|
|
Loading…
Reference in a new issue