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

From: Michael Walle

Date: Mon May 11 2026 - 03:28:27 EST


Hi,

On Fri May 8, 2026 at 2:51 PM CEST, Linus Walleij wrote:
> 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;
> +

Shall we check if the user wants to set an incorrect direction and
return -EINVAL?

-michael

> if (gpio->reg_dir_out_base) {
> base = gpio_regmap_addr(gpio->reg_dir_out_base);
> invert = 0;

Attachment: signature.asc
Description: PGP signature