]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/gpio/gpiolib.c
gpiolib: fix up emulated open drain outputs
[mirror_ubuntu-bionic-kernel.git] / drivers / gpio / gpiolib.c
index 7c0dc2b42f0c4ed4144447bfc648c5897a01d523..4fb7cb2a796718adf996a92aab88aa5cb79e4426 100644 (file)
@@ -209,6 +209,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 status;