[PATCH] lib: utils: Add fdt_fixup_node() helper function

Anup Patel anup at brainfault.org
Mon Dec 5 04:26:16 PST 2022


On Fri, Dec 2, 2022 at 5:30 PM Prabhakar <prabhakar.csengg at gmail.com> wrote:
>
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj at bp.renesas.com>
>
> Add a helper function fdt_fixup_node() based on the compatible string.
> This will avoid code duplication for every new node fixup being added.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj at bp.renesas.com>

Looks good to me.

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

I have taken care of Bin's comment at the time of merging this patch.
Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  lib/utils/fdt/fdt_fixup.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index d1050bb..ef06c6b 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -74,22 +74,22 @@ static void fdt_domain_based_fixup_one(void *fdt, int nodeoff)
>         }
>  }
>
> -void fdt_aplic_fixup(void *fdt)
> +static void fdt_fixup_node(void *fdt, const char *compatible)
>  {
>         int noff = 0;
>
> -       while ((noff = fdt_node_offset_by_compatible(fdt, noff,
> -                                                    "riscv,aplic")) >= 0)
> +       while ((noff = fdt_node_offset_by_compatible(fdt, noff, compatible)) >= 0)
>                 fdt_domain_based_fixup_one(fdt, noff);
>  }
>
> -void fdt_imsic_fixup(void *fdt)
> +void fdt_aplic_fixup(void *fdt)
>  {
> -       int noff = 0;
> +       fdt_fixup_node(fdt, "riscv,aplic");
> +}
>
> -       while ((noff = fdt_node_offset_by_compatible(fdt, noff,
> -                                                    "riscv,imsics")) >= 0)
> -               fdt_domain_based_fixup_one(fdt, noff);
> +void fdt_imsic_fixup(void *fdt)
> +{
> +       fdt_fixup_node(fdt, "riscv,imsics");
>  }
>
>  void fdt_plic_fixup(void *fdt)
> --
> 2.17.1
>



More information about the opensbi mailing list