Skip to content

Commit

Permalink
gpio: generic: clamp retured value to [0,1]
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Walleij committed Feb 6, 2014
1 parent f86b7c7 commit 25b35da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 25b35da

Please sign in to comment.