[U-Boot] [PATCH 05/23] fdt: Add a subnodes iterator macro

Thierry Reding thierry.reding at gmail.com
Tue Aug 19 14:22:00 CEST 2014


On Mon, Aug 18, 2014 at 12:11:03PM -0600, Simon Glass wrote:
> On 18 August 2014 01:16, Thierry Reding <thierry.reding at gmail.com> wrote:
> > From: Thierry Reding <treding at nvidia.com>
> >
> > The fdt_for_each_subnode() iterator macro provided by this patch can be
> > used to iterate over a device tree node's subnodes. At each iteration a
> > loop variable will be set to the next subnode.
> >
> > Signed-off-by: Thierry Reding <treding at nvidia.com>
> 
> Acked-by: Simon Glass <sjg at chromium.org>
> 
> Will this go upstream to dtc at some point?

I suppose it could. I don't know anything about how code flows back and
forth between dtc and U-Boot.

> > ---
> >  include/libfdt.h | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >
> > diff --git a/include/libfdt.h b/include/libfdt.h
> > index 4d7fb2681669..0330d7a29a58 100644
> > --- a/include/libfdt.h
> > +++ b/include/libfdt.h
> > @@ -163,6 +163,26 @@ int fdt_first_subnode(const void *fdt, int offset);
> >   */
> >  int fdt_next_subnode(const void *fdt, int offset);
> >
> > +/**
> > + * fdt_for_each_subnode - iterate over all subnodes of a parent
> > + *
> > + * This is actually a wrapper around a for loop and would be used like so:
> > + *
> > + *     fdt_for_each_subnode(fdt, node, parent) {
> > + *             ...
> > + *             use node
> > + *             ...
> > + *     }
> > + *
> > + * @fdt:       FDT blob
> > + * @node:      child node
> > + * @parent:    parent node
> 
> It might be worth mentioning the type of each of these since it is not
> in the macro.

Will do.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140819/ee8fab39/attachment.pgp>


More information about the U-Boot mailing list