gpio: em: Be sure to clamp return value
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 21 Dec 2015 09:46:18 +0000 (10:46 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 26 Dec 2015 21:28:07 +0000 (22:28 +0100)
As we want gpio_chip .get() calls to be able to return negative
error codes and propagate to drivers, we need to go over all
drivers and make sure their return values are clamped to [0,1].
We do this by using the ret = !!(val) design pattern.

Cc: Magnus Damm <damm@opensource.se>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-em.c

index c3ca2b1c1dfe1cb4a444bdd5ec2c54ad9415a038..d726c68c4a65d779c8e34859ca2aff63f249ee8f 100644 (file)
@@ -203,7 +203,7 @@ static int em_gio_direction_input(struct gpio_chip *chip, unsigned offset)
 
 static int em_gio_get(struct gpio_chip *chip, unsigned offset)
 {
-       return (int)(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset));
+       return !!(em_gio_read(gpio_to_priv(chip), GIO_I) & BIT(offset));
 }
 
 static void __em_gio_set(struct gpio_chip *chip, unsigned int reg,
This page took 0.02606 seconds and 5 git commands to generate.