[PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line

From: Linus Walleij

Date: Fri May 08 2026 - 08:51:49 EST


If a GPIO line has a fixed direction, there is no point in
trying to set the direction.

This didn't happen much before because what we supported was
all lines input or output and then the implementer would
probably not specify the direction registers, but with
sparse fixed direction we can have a mixture so let's take
this into account.

Suggested-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Link: https://sashiko.dev/#/patchset/20260507-regmap-gpio-sparse-fixed-dir-v1-1-a2e5855e2701%40kernel.org
Signed-off-by: Linus Walleij <linusw@xxxxxxxxxx>
---
drivers/gpio/gpio-regmap.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index f45a432e8ebe..52a67dea8107 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -203,6 +203,9 @@ static int gpio_regmap_set_direction(struct gpio_chip *chip,
unsigned int base, val, reg, mask;
int invert, ret;

+ if (gpio_regmap_fixed_direction(gpio, offset))
+ return 0;
+
if (gpio->reg_dir_out_base) {
base = gpio_regmap_addr(gpio->reg_dir_out_base);
invert = 0;

--
2.54.0