gpio: tz1090-pdc: Be sure to clamp return value
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 21 Dec 2015 13:54:59 +0000 (14:54 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 26 Dec 2015 21:28:29 +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.

Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-tz1090-pdc.c

index 0a01c8736affaceecb8fb46ef971456ca77b9f18..b08b22b1b1111dc5c08cf307d8398496df2f6d82 100644 (file)
@@ -113,7 +113,7 @@ static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip,
 static int tz1090_pdc_gpio_get(struct gpio_chip *chip, unsigned int offset)
 {
        struct tz1090_pdc_gpio *priv = to_pdc(chip);
-       return pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset);
+       return !!(pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset));
 }
 
 static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset,
This page took 0.024701 seconds and 5 git commands to generate.