summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2015-12-17 10:14:24 +0100
committerLinus Walleij <linus.walleij@linaro.org>2015-12-17 15:48:29 +0100
commit45ad7db90b42555c8107f18ec6d6a1e9bce34860 (patch)
tree95308f6db9e1583891df11f44015aa1f23b56ff4
parent67a76aafec00db46fbd65d7d17a1cde1adde70c5 (diff)
downloadop-kernel-dev-45ad7db90b42555c8107f18ec6d6a1e9bce34860.zip
op-kernel-dev-45ad7db90b42555c8107f18ec6d6a1e9bce34860.tar.gz
gpio: revert get() to non-errorprogating behaviour
commit e20538b82f1f ("gpio: Propagate errors from chip->get()") started to propagate errors from the .get() functions since we can get errors from the infrastructure of e.g. slowbus GPIO expanders. However it turns out a bunch of drivers relied on the core to clamp the value, so we need to revert to the old behaviour and go over all drivers and fix them to conform to the expectations of the core before we go back to propagating the error code. Cc: stable@vger.kernel.org # 4.3+ Cc: Bjorn Andersson <bjorn.andersson@sonymobile.com> Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()") Reported-by: Michael Trimarchi <michael@amarulasolutions.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpiolib.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2a91f32..4e4c308 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc)
chip = desc->chip;
offset = gpio_chip_hwgpio(desc);
value = chip->get ? chip->get(chip, offset) : -EIO;
- value = value < 0 ? value : !!value;
+ /*
+ * FIXME: fix all drivers to clamp to [0,1] or return negative,
+ * then change this to:
+ * value = value < 0 ? value : !!value;
+ * so we can properly propagate error codes.
+ */
+ value = !!value;
trace_gpio_value(desc_to_gpio(desc), 1, value);
return value;
}
OpenPOWER on IntegriCloud