Re: [PATCH v4 06/11] gpio: regmap: add the .fixed_direction_output configuration parameter

From: Michael Walle

Date: Fri Sep 19 2025 - 10:07:04 EST


Hi,

> > > @@ -129,6 +130,13 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
> > > unsigned int base, val, reg, mask;
> > > int invert, ret;
> > >
> > > + if (gpio->fixed_direction_output) {
> > > + if (test_bit(offset, gpio->fixed_direction_output))
> > > + return GPIO_LINE_DIRECTION_OUT;
> > > + else
> > > + return GPIO_LINE_DIRECTION_IN;
> > > + }
> > > +
> > > if (gpio->reg_dat_base && !gpio->reg_set_base)
> > > return GPIO_LINE_DIRECTION_IN;
> > > if (gpio->reg_set_base && !gpio->reg_dat_base)
> > > @@ -277,6 +285,17 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
> > > return ERR_PTR(ret);
> >
> > Not related to your patch, but this line above is wrong. That should
> > be "goto err_free_gpio". Would you mind adding a patch for it? I
> > could do it myself, but it will probably conflict with this series.
> > I'm fine either way (if you do it, don't forget the Fixes: tag).
>
> If this would be the only change, I would not do a v5. If there are more
> things to change, of course.

Fine by me.

> > > }
> > >
> > > + if (config->fixed_direction_output) {
> > > + gpio->fixed_direction_output = bitmap_alloc(chip->ngpio,
> > > + GFP_KERNEL);
> > > + if (!gpio->fixed_direction_output) {
> > > + ret = -ENOMEM;
> > > + goto err_free_gpio;
> > > + }
> > > + bitmap_copy(gpio->fixed_direction_output,
> > > + config->fixed_direction_output, chip->ngpio);
> > > + }
> > > +
> > > /* if not set, assume there is only one register */
> > > gpio->ngpio_per_reg = config->ngpio_per_reg;
> > > if (!gpio->ngpio_per_reg)
> > > @@ -293,7 +312,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
> > >
> > > ret = gpiochip_add_data(chip, gpio);
> > > if (ret < 0)
> > > - goto err_free_gpio;
> > > + goto err_free_bitmap;
> >
> > There's also an err_free_gpio jump below, that should also be
> > replaced with err_free_bitmap.
>
> I am a bit confused. With this patch applied there is only one 'goto
> err_free_gpio' in gpio-regmap.c and that's the one added by me above.
>
> What am I missing?

Probably commit 553b75d4bfe9 ("gpio: regmap: Allow to allocate
regmap-irq device") which was added to the mfd/gpio/next tree a
couple of days ago.

-michael

Attachment: signature.asc
Description: PGP signature