OSDN Git Service

Revert "gpiolib: Split GPIO flags parsing and GPIO configuration"
authorJohan Hovold <johan@kernel.org>
Sun, 3 Jul 2016 16:32:05 +0000 (18:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 16:47:29 +0000 (09:47 -0700)
commit93f25db7b827aa7c6910a19b52455969b5d149ed
tree4eecceb39500fb76541946601c3e3f94dd0eba01
parentd9c5952f0aa481d0b703e05dd1ba6eca374d2dbc
Revert "gpiolib: Split GPIO flags parsing and GPIO configuration"

commit 85b03b3033fd4eba82665b3b9902c095a08cc52f upstream.

This reverts commit 923b93e451db876d1479d3e4458fce14fec31d1c.

Make sure consumers do not overwrite gpio flags for pins that have
already been claimed.

While adding support for gpio drivers to refuse a request using
unsupported flags, the order of when the requested flag was checked and
the new flags were applied was reversed to that consumers could
overwrite flags for already requested gpios.

This not only affects device-tree setups where two drivers could request
the same gpio using conflicting configurations, but also allowed user
space to clear gpio flags for already claimed pins simply by attempting
to export them through the sysfs interface. By for example clearing the
FLAG_ACTIVE_LOW flag this way, user space could effectively change the
polarity of a signal.

Reverting this change obviously prevents gpio drivers from doing sanity
checks on the flags in their request callbacks. Fortunately only one
recently added driver (gpio-tps65218 in v4.6) appears to do this, and a
follow up patch could restore this functionality through a different
interface.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpio/gpiolib-legacy.c
drivers/gpio/gpiolib.c