[PATCH] gpio: generic: Avoid pinctrl calls when ranges are missing

Linus Walleij <[email protected]>
Newsgroups org.kernel.vger.linux-gpio
Message-ID <[email protected]>
Most calls to the pinctrl core is done through the generic helper
that go into gpiolib, where the library checks if there is a range
associated with the chip and just bails out silently if ther isn't.

gpio_mmio_dir_return() misses this check before calling
pinctrl_gpio_direction_output/input().

Fix this up with an explicit range check.

Reported-by: [email protected]
Closes: https://lore.kernel.org/linux-devicetree/[email protected]/
Signed-off-by: Linus Walleij <[email protected]>
---
 drivers/gpio/gpio-mmio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index e9c531eef452..7e4b3e8d609f 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -354,6 +354,11 @@ static int gpio_mmio_dir_return(struct gpio_chip *gc, unsigned int gpio,
 	if (!chip->pinctrl)
 		return 0;
 
+#ifdef CONFIG_PINCTRL
+	if (list_empty(&gc->gpiodev->pin_ranges))
+		return 0;
+#endif
+
 	if (dir_out)
 		return pinctrl_gpio_direction_output(gc, gpio);
 	else

---
base-commit: 9d2ed026f031f764e9450ac9aada2f46bc977397
change-id: 20260820-fix-gpio-mmio-pinctrl-0cab907d1219

Best regards,
--  
Linus Walleij <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.