[PATCH 2/2] reset: Allow reset_get_by_name() with NULL name

Simon Glass sjg at chromium.org
Wed Jan 4 21:01:48 CET 2023


Hi Samuel,

On Sun, 27 Nov 2022 at 22:54, Samuel Holland <samuel at sholland.org> wrote:
>
> This allows devm_reset_control_get(dev, NULL) to work and get the first
> reset control, which is common in code ported from Linux.
>
> Signed-off-by: Samuel Holland <samuel at sholland.org>
> ---
>
>  drivers/reset/reset-uclass.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
> index bcef46039c2..a26c623a77e 100644
> --- a/drivers/reset/reset-uclass.c
> +++ b/drivers/reset/reset-uclass.c
> @@ -147,13 +147,14 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
>  int reset_get_by_name(struct udevice *dev, const char *name,
>                      struct reset_ctl *reset_ctl)
>  {
> -       int index;
> +       int index = 0;
>
>         debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
>               reset_ctl);
>         reset_ctl->dev = NULL;
>
> -       index = dev_read_stringlist_search(dev, "reset-names", name);
> +       if (name)
> +               index = dev_read_stringlist_search(dev, "reset-names", name);
>         if (index < 0) {
>                 debug("fdt_stringlist_search() failed: %d\n", index);
>                 return index;

The above three lines should only be used when name is NULL.

> --
> 2.37.4
>

Please update the function comment in the header file and add a test
for this to test/dm/reset.c

Regards,
Simon


More information about the U-Boot mailing list