Message ID | 20221202115947.226472-1-prabhakar.mahadev-lad.rj@bp.renesas.com |
---|---|
State | Accepted |
Headers | show |
Series | lib: utils: Add fdt_fixup_node() helper function | expand |
On Fri, Dec 2, 2022 at 8:00 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@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@bp.renesas.com> > --- > 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) nits: 80 characters per line limit? > 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) > -- Reviewed-by: Bin Meng <bmeng@tinylab.org>
在 2022-12-02星期五的 11:59 +0000,Prabhakar写道: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@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@bp.renesas.com> Look good to me Reviewed-by: Xiang W <wxjstz@126.com> > --- > 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 > >
On Fri, Dec 2, 2022 at 5:30 PM Prabhakar <prabhakar.csengg@gmail.com> wrote: > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@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@bp.renesas.com> Looks good to me. Reviewed-by: Anup Patel <anup@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 >
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)