summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2020-01-17 08:59:29 +0100
committerLinus Walleij <linus.walleij@linaro.org>2020-01-17 08:59:29 +0100
commit6a77de2596a8d02cbfe9cebe448d8575e4354c9a (patch)
tree13e7621c147ef1415195213089ce3c2c94590bde /drivers/gpio/gpiolib.c
parent59c324683400b41caa6d85b091e812ee3d5415c3 (diff)
parentb3a987b0264d3ddbb24293ebff10eddfc472f653 (diff)
downloadlinux-6a77de2596a8d02cbfe9cebe448d8575e4354c9a.tar.bz2
Merge tag 'v5.5-rc6' into devel
Linux 5.5-rc6
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6d04e444f422..4275b8d771ad 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -220,6 +220,14 @@ int gpiod_get_direction(struct gpio_desc *desc)
chip = gpiod_to_chip(desc);
offset = gpio_chip_hwgpio(desc);
+ /*
+ * Open drain emulation using input mode may incorrectly report
+ * input here, fix that up.
+ */
+ if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) &&
+ test_bit(FLAG_IS_OUT, &desc->flags))
+ return 0;
+
if (!chip->get_direction)
return -ENOTSUPP;
@@ -4456,8 +4464,9 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
if (chip->ngpio <= p->chip_hwnum) {
dev_err(dev,
- "requested GPIO %d is out of range [0..%d] for chip %s\n",
- idx, chip->ngpio, chip->label);
+ "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n",
+ idx, p->chip_hwnum, chip->ngpio - 1,
+ chip->label);
return ERR_PTR(-EINVAL);
}