]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
gpio: clamp returned values to the boolean range
authorAlexandre Courbot <acourbot@nvidia.com>
Tue, 11 Mar 2014 06:52:09 +0000 (15:52 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 14 Mar 2014 09:17:03 +0000 (10:17 +0100)
commit23600969ff137cf4c3bc9098f77e381de334e3f7
treead8bcad3af9b5635323b90cf0de346a1ee5db7c3
parent6072b9dcf97870c9e840ad91862da7ff8ed680ee
gpio: clamp returned values to the boolean range

Nothing prevents GPIO drivers from returning values outside the
boolean range, and as it turns out a few drivers are actually doing so.
These values were passed as-is to unsuspecting consumers and created
confusion.

This patch makes the internal _gpiod_get_raw_value() function return a
bool, effectively clamping the GPIO value to the boolean range no
matter what the driver does.

While we are at it, we also change the value parameter of
_gpiod_set_raw_value() to bool type before drivers start doing funny
things with it as well.

Another way to fix this would be to change the prototypes of the driver
interface to use bool directly, but this would require a huge
cross-systems patch so this simpler solution is preferred.

Changes since v1:
- Change local variable type to bool as well, use boolean values in
  code
- Also change prototype of open drain/open source setting functions
  since they are only called from _gpiod_set_raw_value()

This probably calls for a larger booleanization of gpiolib, but let's
keep that for a latter change - right now we need to address the issue
of non-boolean values returned by drivers.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c