Re: [PATCH v6 6/8] gpio: regmap: Add set_config callback

From: Michael Walle

Date: Tue Jul 21 2026 - 03:23:47 EST


On Tue Jul 21, 2026 at 8:58 AM CEST, Yu-Chun Lin wrote:
> Add a new set_config callback to struct gpio_regmap_config to allow drivers
> to implement hardware-specific configuration such as debounce settings,
> or other platform-specific GPIO properties.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
> Signed-off-by: Yu-Chun Lin <eleanor.lin@xxxxxxxxxxx>
> ---
> Changes in v6:
> - None.
> ---
> drivers/gpio/gpio-regmap.c | 1 +
> include/linux/gpio/regmap.h | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
> index aecc35f610dd..b856326ff01c 100644
> --- a/drivers/gpio/gpio-regmap.c
> +++ b/drivers/gpio/gpio-regmap.c
> @@ -454,6 +454,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
> gpio->reg_mask_xlate = gpio_regmap_simple_xlate;
>
> gpio->value_xlate = config->value_xlate;
> + chip->set_config = config->set_config;
>
> ret = gpiochip_add_data(chip, gpio);
> if (ret < 0)
> diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
> index 45a30f50043f..23460995c1d1 100644
> --- a/include/linux/gpio/regmap.h
> +++ b/include/linux/gpio/regmap.h
> @@ -89,6 +89,9 @@ enum gpio_regmap_operation {
> * mask before writing. This allows driver-specific logic
> * to append additional bits (like write-enable masks)
> * dynamically based on the current operation.
> + * @set_config: (Optional) Callback for setting GPIO configuration such
> + * as debounce, drive strength, or other hardware specific
> + * settings.
> * @drvdata: (Optional) Pointer to driver specific data which is
> * not used by gpio-remap but is provided "as is" to the
> * driver callback(s).
> @@ -150,6 +153,8 @@ struct gpio_regmap_config {
> unsigned int base, unsigned int offset, unsigned int reg,
> unsigned int *mask, unsigned int *val);
>
> + int (*set_config)(struct gpio_chip *gc, unsigned int offset, unsigned long config);
> +

Do we need an additional struct gpio_regmap pointer as a first
argument? How does the driver fetch the attached opaque data
pointer? I see that your driver is doing

struct rtd1625_gpio *data = gpiochip_get_data(chip)

But it is the gpio-regmap core which will attach it's own data
pointer to gpio_chip, no?

-michael

> void *drvdata;
> };
>

Attachment: signature.asc
Description: PGP signature