]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit
gpiolib: never report open-drain/source lines as 'input' to user-space
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 6 Aug 2019 11:41:51 +0000 (13:41 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 4 Sep 2019 09:38:39 +0000 (11:38 +0200)
commitc0cb232c91f23532cbb7da553ded7f5fc28370ba
tree6d7350cd690021e83c337ecf449f0b08e4e22a41
parentda85ebad8df7b754da04ac585c108f2df23cdb99
gpiolib: never report open-drain/source lines as 'input' to user-space

BugLink: https://bugs.launchpad.net/bugs/1842128
commit 2c60e6b5c9241b24b8b523fefd3e44fb85622cda upstream.

If the driver doesn't support open-drain/source config options, we
emulate this behavior when setting the direction by calling
gpiod_direction_input() if the default value is 0 (open-source) or
1 (open-drain), thus not actively driving the line in those cases.

This however clears the FLAG_IS_OUT bit for the GPIO line descriptor
and makes the LINEINFO ioctl() incorrectly report this line's mode as
'input' to user-space.

This commit modifies the ioctl() to always set the GPIOLINE_FLAG_IS_OUT
bit in the lineinfo structure's flags field. Since it's impossible to
use the input mode and open-drain/source options at the same time, we
can be sure the reported information will be correct.

Fixes: 521a2ad6f862 ("gpio: add userspace ABI for GPIO line information")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20190806114151.17652-1-brgl@bgdev.pl
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/gpio/gpiolib.c