]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: generic: clamp values from bgpio_get_set()
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 10 Dec 2015 14:55:29 +0000 (15:55 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 17 Dec 2015 14:47:38 +0000 (15:47 +0100)
commit458fbf198c1d014f28ad24f092dffadd7405cdab
tree0f1373bf6ffc834c42738d80d79db00616f599ea
parent52361f49ba1c66e1c69851e0b35bd788531ccbcc
gpio: generic: clamp values from bgpio_get_set()

The bgpio_get_set() call should return a value clamped to [0,1],
the current code will return a negative value if reading
bit 31, which turns the value negative as this is a signed value
and thus gets interpreted as an error by the gpiolib core.
Found on the gpio-mxc but applies to any MMIO driver.

Cc: stable@vger.kernel.org # 4.3+
Cc: kernel@pengutronix.de
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Fixes: 7d685d726162 ("gpio: Propagate errors from chip->get()")
Reported-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-generic.c