gpio: janz-ttl: Be sure to clamp return value
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 21 Dec 2015 10:03:33 +0000 (11:03 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 26 Dec 2015 21:28:10 +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: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-janz-ttl.c

index e5f85cab010079dd8e484ea63296dd8ec1c0ca96..236d322a0b5e51e4963834119d259fab5ba32af8 100644 (file)
@@ -76,7 +76,7 @@ static int ttl_get_value(struct gpio_chip *gpio, unsigned offset)
        spin_lock(&mod->lock);
        ret = *shadow & (1 << offset);
        spin_unlock(&mod->lock);
-       return ret;
+       return !!ret;
 }
 
 static void ttl_set_value(struct gpio_chip *gpio, unsigned offset, int value)
This page took 0.025967 seconds and 5 git commands to generate.