Skip to contentSkip to conversation

gpiolib: Don't free if pin ranges are not defined

PATCH Applied Will McVicker 2 participants 3 messages Nov 30, 2020 – Dec 1, 2020 GPIO

lore
Share & tools
lore
#0 lore raw

cover gpiolib: Don't free if pin ranges are not defined

This patch fixes commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges") where an imbalance of requests and frees to the pinctrl driver were introduced.

Edmond Chung (1):
gpiolib: Don't free if pin ranges are not defined

 drivers/gpio/gpiolib.c | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#1 lore raw

PATCH 1/1 gpiolib: Don't free if pin ranges are not defined

From: Edmond Chung <[email protected]>

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")
---
 drivers/gpio/gpiolib.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpio/gpiolib.c +5 -0
index 089ddcaa9bc6..6e3c4d7a7d14 100644
@@ -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);
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#2 lore raw
Quoted 32 lines · Will McVicker

From: Edmond Chung <[email protected]>

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")
---
 drivers/gpio/gpiolib.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpio/gpiolib.c +5 -1
index 089ddcaa9bc6..6e3c4d7a7d14 100644
@@ -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);
--
Quoted 2 lines

2.29.2.454.gaff20da3a2-goog

Applied, thanks!

Bartosz