summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-21 04:30:02 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-12-26 16:28:06 -0500
commit1f66adfb5eb81428bc1a5700cffd22ba8e772272 (patch)
treedd267fb9b1bfb47d856edab67e64ee47cbf8f297
parent50e8df09e4baaad4fa563564dc04663f662a9b68 (diff)
gpio: da9052: Be sure to clamp return value
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: Ashish Jangam <ashish.jangam@kpitcummins.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-da9052.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c
index 2e9578ec0ca1..38bd8f122bfc 100644
--- a/drivers/gpio/gpio-da9052.c
+++ b/drivers/gpio/gpio-da9052.c
@@ -89,15 +89,12 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset)
89 DA9052_STATUS_D_REG); 89 DA9052_STATUS_D_REG);
90 if (ret < 0) 90 if (ret < 0)
91 return ret; 91 return ret;
92 if (ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset))) 92 return !!(ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset)));
93 return 1;
94 else
95 return 0;
96 case DA9052_OUTPUT_PUSHPULL: 93 case DA9052_OUTPUT_PUSHPULL:
97 if (da9052_gpio_port_odd(offset)) 94 if (da9052_gpio_port_odd(offset))
98 return ret & DA9052_GPIO_ODD_PORT_MODE; 95 return !!(ret & DA9052_GPIO_ODD_PORT_MODE);
99 else 96 else
100 return ret & DA9052_GPIO_EVEN_PORT_MODE; 97 return !!(ret & DA9052_GPIO_EVEN_PORT_MODE);
101 default: 98 default:
102 return -EINVAL; 99 return -EINVAL;
103 } 100 }