gpio: intel-mid: Be sure to clamp return value
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 21 Dec 2015 10:00:56 +0000 (11:00 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 26 Dec 2015 21:28:09 +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: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-intel-mid.c

index 1c46a7ef268078f04a360c1a0b205185d660df58..26d2083a59012875db603c35c6f10f377eadbb3b 100644 (file)
@@ -120,7 +120,7 @@ static int intel_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
        void __iomem *gplr = gpio_reg(chip, offset, GPLR);
 
-       return readl(gplr) & BIT(offset % 32);
+       return !!(readl(gplr) & BIT(offset % 32));
 }
 
 static void intel_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
This page took 0.026983 seconds and 5 git commands to generate.