Re: [PATCH v8 2/3] gpio: Add fwnode_gpiod_get() helper
From: Bartosz Golaszewski
Date: Fri Mar 13 2026 - 10:15:07 EST
On Fri, 13 Mar 2026 08:08:41 +0100, Krishna Chaitanya Chundru
<krishna.chundru@xxxxxxxxxxxxxxxx> said:
> Add fwnode_gpiod_get() as a convenience wrapper around
> fwnode_gpiod_get_index() for the common case where only the
> first GPIO is required.
>
> This mirrors existing gpiod_get() and devm_gpiod_get() helpers
> and avoids open-coding index 0 at call sites.
>
> Suggested-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Acked-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@xxxxxxxxxxxxxxxx>
> ---
> include/linux/gpio/consumer.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
> index 0d8408582918680bfea6a04ccedfc0c75211907a..fee926c0262ce9dc4b9a3c151e74f2cf37470a49 100644
> --- a/include/linux/gpio/consumer.h
> +++ b/include/linux/gpio/consumer.h
> @@ -596,6 +596,15 @@ static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
> }
> #endif /* CONFIG_GPIOLIB && CONFIG_HTE */
>
> +static inline
> +struct gpio_desc *fwnode_gpiod_get(struct fwnode_handle *fwnode,
> + const char *con_id,
> + enum gpiod_flags flags,
> + const char *label)
> +{
> + return fwnode_gpiod_get_index(fwnode, con_id, 0, flags, label);
> +}
> +
> static inline
> struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
> struct fwnode_handle *fwnode,
>
> --
> 2.34.1
>
>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>