Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: htc-egpio: 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: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Linus Walleij and committed by
Lee Jones
f7d62366 2d5f72b8

+1 -1
+1 -1
drivers/mfd/htc-egpio.c
··· 163 163 value = egpio_readw(ei, reg); 164 164 pr_debug("readw(%p + %x) = %x\n", 165 165 ei->base_addr, reg << ei->bus_shift, value); 166 - return value & bit; 166 + return !!(value & bit); 167 167 } 168 168 169 169 static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)