gpio: rcar: clamp returned value to [0,1]
authorJürg Billeter <j@bitron.ch>
Tue, 24 Jun 2014 02:19:50 +0000 (04:19 +0200)
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>
Wed, 4 Feb 2015 10:15:30 +0000 (11:15 +0100)
While it will be clamped to bool by gpiolib, let's make this sane
in the driver as well.

Signed-off-by: Jürg Billeter <j@bitron.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 7cb5409b10d9f8316ca2539591acb6a5f7fd4139)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
drivers/gpio/gpio-rcar.c

index b6ae89e..0d251dc 100644 (file)
@@ -240,9 +240,9 @@ static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset)
        /* testing on r8a7790 shows that INDT does not show correct pin state
         * when configured as output, so use OUTDT in case of output pins */
        if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit)
-               return (int)(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
+               return !!(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
        else
-               return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
+               return !!(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
 }
 
 static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)