[PATCH] lib: utils/reset: Try initializing all reset devices in dt

Anup Patel anup at brainfault.org
Thu Jun 13 20:07:34 PDT 2024


On Thu, Jun 13, 2024 at 8:35 PM Xiang W <wxjstz at 126.com> wrote:
>
> In DT, multiple reset devices may use the same driver, and they
> may have different priorities. If rc is returned after the first
> initialization, the highest priority device may be lost.

Multiple reset devices of the same driver with different priorities
is extremely rare. Nevertheless, this patch does not break anything
so I am okay.

>
> Fixes: a73ff043e991 (lib: utils/reset: Fix fdt_reset to search for more dt nodes)
> Signed-off-by: Xiang W <wxjstz at 126.com>

Reviewed-by: Anup Patel <anup at brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  lib/utils/reset/fdt_reset.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c
> index c41b838..ee4e29a 100644
> --- a/lib/utils/reset/fdt_reset.c
> +++ b/lib/utils/reset/fdt_reset.c
> @@ -19,7 +19,7 @@ extern unsigned long fdt_reset_drivers_size;
>
>  int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)
>  {
> -       int noff, rc = SBI_ENODEV;
> +       int noff, rc, cnt = 0;
>         const struct fdt_match *match;
>
>         noff = -1;
> @@ -30,16 +30,16 @@ int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)
>
>                 if (drv->init) {
>                         rc = drv->init(fdt, noff, match);
> -                       if (rc && rc != SBI_ENODEV) {
> +                       if (!rc)
> +                               cnt++;
> +                       else if (rc != SBI_ENODEV) {
>                                 sbi_printf("%s: %s init failed, %d\n",
>                                         __func__, match->compatible, rc);
>                         }
>                 }
> -
> -               return rc;
>         }
>
> -       return SBI_ENODEV;
> +       return cnt > 0 ? 0 : SBI_ENODEV;
>  }
>
>  void fdt_reset_init(void)
> --
> 2.43.0
>



More information about the opensbi mailing list