Re: [PATCH v2 9/9] reset: gpio: use software nodes to setup the GPIO lookup
From: Philipp Zabel
Date: Wed Oct 22 2025 - 10:45:43 EST
On Mi, 2025-10-22 at 15:41 +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> GPIO machine lookup is a nice mechanism for associating GPIOs with
> consumers if we don't know what kind of device the GPIO provider is or
> when it will become available. However in the case of the reset-gpio, we
> are already holding a reference to the device and so can reference its
> firmware node. Let's setup a software node that references the relevant
> GPIO and attach it to the auxiliary device we're creating.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> ---
> drivers/reset/core.c | 131 ++++++++++++++++++++++++++++++---------------------
> 1 file changed, 77 insertions(+), 54 deletions(-)
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index c9f13020ca3a7b9273488497a7d4240d0af762b0..20378de4b813ab79a103ea81cf2cbcd2b76c0ccf 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
[...]
> @@ -915,11 +913,30 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
> if (args->args_count != 2)
> return -ENOENT;
>
> + offset = args->args[0];
> + of_flags = args->args[1];
> +
> + /*
> + * Later we map GPIO flags between OF and Linux, however not all
> + * constants from include/dt-bindings/gpio/gpio.h and
> + * include/linux/gpio/machine.h match each other.
> + *
> + * FIXME: Find a better way of translating OF flags to GPIO lookup
> + * flags.
> + */
> + if (of_flags > GPIO_ACTIVE_LOW) {
> + pr_err("reset-gpio code does not support GPIO flags %u for GPIO %u\n",
> + of_flags, offset);
> + return -EINVAL;
> + }
> +
Please move this ...
> struct gpio_device *gdev __free(gpio_device_put) =
> gpio_device_find_by_fwnode(of_fwnode_handle(args->np));
> if (!gdev)
> return -EPROBE_DEFER;
>
> + parent = gpio_device_to_device(gdev);
> +
... and this after the lockdep_asset_held() below.
With that,
Reviewed-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
regards
Philipp