summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorEdmond Chung <edmondchung@google.com>2020-11-30 22:47:53 +0000
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2020-12-02 10:40:55 +0100
commit6dbbf84603961d4e8eaea46e3530373c8cffee67 (patch)
treea8e66c902eebae129d1d4296cb668b9dfeec8aca /drivers/gpio/gpiolib.c
parent60593df667e087b009ee0fc20d92e9c4c096a9b5 (diff)
downloadlinux-6dbbf84603961d4e8eaea46e3530373c8cffee67.tar.gz
linux-6dbbf84603961d4e8eaea46e3530373c8cffee67.tar.bz2
linux-6dbbf84603961d4e8eaea46e3530373c8cffee67.zip
gpiolib: Don't free if pin ranges are not defined
A similar check was added in gpiochip_generic_request, but not in free. This has caused an imbalance count of request vs. free calls to the pinctrl driver. This patch is targeted to fix that issue. Fixes: 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges") Signed-off-by: Edmond Chung <edmondchung@google.com> Signed-off-by: Andrew Chant <achant@google.com> Signed-off-by: Will McVicker <willmcvicker@google.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 089ddcaa9bc6..6e3c4d7a7d14 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1806,6 +1806,11 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_request);
*/
void gpiochip_generic_free(struct gpio_chip *gc, unsigned offset)
{
+#ifdef CONFIG_PINCTRL
+ if (list_empty(&gc->gpiodev->pin_ranges))
+ return;
+#endif
+
pinctrl_gpio_free(gc->gpiodev->base + offset);
}
EXPORT_SYMBOL_GPL(gpiochip_generic_free);