All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: "Pantelis Antoniou"
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	"Boris Brezillon"
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	"Alexander Kaplan" <alex-MflLfwwFzuz+yO7R74ARew@public.gmane.org>,
	"Thomas Petazzoni"
	<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Simon Glass" <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	"Antoine Ténart"
	<antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	"Thierry Reding"
	<treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH 1/4] libfdt: Add a subnodes iterator macro
Date: Tue, 31 May 2016 10:54:33 +1000	[thread overview]
Message-ID: <20160531005433.GH17226@voom.fritz.box> (raw)
In-Reply-To: <20160531004719.GF17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2630 bytes --]

On Tue, May 31, 2016 at 10:47:19AM +1000, David Gibson wrote:
> On Fri, May 27, 2016 at 10:28:46AM +0200, Maxime Ripard wrote:
> > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > 
> > 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-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> > Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> Looks good, but needs a testcase.  Extending subnode_iterate would
> probably make sense.

Sorry, one other thing, as I noted on 2/4, I prefer the convention
where the loop counter (so the subnode offset in this case) is the
first argument to foreach style macros.

> 
> > ---
> >  libfdt/libfdt.h | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> > 
> > diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
> > index 36222fd4a6f4..331f32dd04b5 100644
> > --- a/libfdt/libfdt.h
> > +++ b/libfdt/libfdt.h
> > @@ -168,6 +168,31 @@ 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
> > + *		...
> > + *	}
> > + *
> > + * Note that this is implemented as a macro and node is used as iterator in
> > + * the loop. It should therefore be a locally allocated variable. The parent
> > + * variable on the other hand is never modified, so it can be constant or
> > + * even a literal.
> > + *
> > + * @fdt:	FDT blob (const void *)
> > + * @node:	child node (int)
> > + * @parent:	parent node (int)
> > + */
> > +#define fdt_for_each_subnode(fdt, node, parent)		\
> > +	for (node = fdt_first_subnode(fdt, parent);	\
> > +	     node >= 0;					\
> > +	     node = fdt_next_subnode(fdt, node))
> > +
> >  /**********************************************************************/
> >  /* General functions                                                  */
> >  /**********************************************************************/
> 



-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-05-31  0:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27  8:28 [PATCH 0/4] libfdt: Add support for device tree overlays Maxime Ripard
     [not found] ` <1464337729-7821-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-27  8:28   ` [PATCH] fdt: Add a subnodes iterator macro Maxime Ripard
2016-05-27  8:28   ` [PATCH 1/4] libfdt: " Maxime Ripard
     [not found]     ` <1464337729-7821-3-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-31  0:47       ` David Gibson
     [not found]         ` <20160531004719.GF17226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-05-31  0:54           ` David Gibson [this message]
2016-05-27  8:28   ` [PATCH 2/4] libfdt: Add iterator over properties Maxime Ripard
     [not found]     ` <1464337729-7821-4-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-31  0:53       ` David Gibson
2016-05-27  8:28   ` [PATCH 3/4] libfdt: Add max phandle retrieval function Maxime Ripard
     [not found]     ` <1464337729-7821-5-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-31  1:02       ` David Gibson
2016-05-27  8:28   ` [PATCH 4/4] libfdt: Add overlay application function Maxime Ripard
     [not found]     ` <1464337729-7821-6-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-02  5:23       ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160531005433.GH17226@voom.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=alex-MflLfwwFzuz+yO7R74ARew@public.gmane.org \
    --cc=antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.