From: Stefan Agner <stefan@agner.ch>
To: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Tom Rini <trini@konsulko.com>,
u-boot@lists.denx.de,
Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
Alexander Kaplan <alex@nextthing.co>,
devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH v2 5/9] libfdt: Add iterator over properties
Date: Thu, 09 Jun 2016 19:51:23 -0700 [thread overview]
Message-ID: <f00eb3469391b1d3d473c227531cf7a7@agner.ch> (raw)
In-Reply-To: <1464340402-2249-6-git-send-email-maxime.ripard@free-electrons.com>
On 2016-05-27 02:13, Maxime Ripard wrote:
> Implement a macro based on fdt_first_property_offset and
> fdt_next_property_offset that provides a convenience to iterate over all
> the properties of a given node.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> include/libfdt.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
Reviewed-by: Stefan Agner <stefan@agner.ch>
There would be already be several opportunities in existing code to use
that :-)
>
> diff --git a/include/libfdt.h b/include/libfdt.h
> index 74b1d149c2dd..4e8eb9ede3a4 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -441,6 +441,30 @@ int fdt_first_property_offset(const void *fdt,
> int nodeoffset);
> int fdt_next_property_offset(const void *fdt, int offset);
>
> /**
> + * fdt_for_each_property - iterate over all properties of a node
> + * @fdt: FDT blob (const void *)
> + * @node: node offset (int)
> + * @property: property offset (int)
> + *
> + * This is actually a wrapper around a for loop and would be used like so:
> + *
> + * fdt_for_each_property(fdt, node, property) {
> + * ...
> + * use property
> + * ...
> + * }
> + *
> + * Note that this is implemented as a macro and property is used as
> + * iterator in the loop. It should therefore be a locally allocated
> + * variable. The node variable on the other hand is never modified, so
> + * it can be constant or even a literal.
> + */
> +#define fdt_for_each_property(fdt, node, property) \
> + for (property = fdt_first_property_offset(fdt, node); \
> + property >= 0; \
> + property = fdt_next_property_offset(fdt, property))
> +
> +/**
> * fdt_get_property_by_offset - retrieve the property at a given offset
> * @fdt: pointer to the device tree blob
> * @offset: offset of the property to retrieve
next prev parent reply other threads:[~2016-06-10 2:51 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-27 9:13 [PATCH v2 0/9] cmd: fdt: Add device tree overlays support Maxime Ripard
[not found] ` <1464340402-2249-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-05-27 9:13 ` [PATCH v2 1/9] cmd: fdt: Narrow the check for fdt addr Maxime Ripard
[not found] ` <1464340402-2249-2-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 13:55 ` Pantelis Antoniou
2016-05-27 9:13 ` [PATCH v2 2/9] scripts: Makefile.lib: Sanitize DTB names Maxime Ripard
[not found] ` <1464340402-2249-3-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 13:59 ` Pantelis Antoniou
2016-05-27 9:13 ` [PATCH v2 3/9] vsprintf: Include stdarg for va_list Maxime Ripard
[not found] ` <1464340402-2249-4-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 14:00 ` Pantelis Antoniou
2016-05-27 9:13 ` [PATCH v2 4/9] libfdt: Add new headers and defines Maxime Ripard
[not found] ` <1464340402-2249-5-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 14:03 ` Pantelis Antoniou
[not found] ` <D44ABB0F-69B9-4DA6-8F8B-6F74A5B4BFE1-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-11 10:30 ` David Gibson
[not found] ` <20160611103035.GW9226-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-06-13 9:28 ` Maxime Ripard
2016-06-16 0:39 ` Simon Glass
2016-05-27 9:13 ` [PATCH v2 5/9] libfdt: Add iterator over properties Maxime Ripard
2016-06-10 2:51 ` Stefan Agner [this message]
2016-06-10 14:04 ` Pantelis Antoniou
[not found] ` <73A48AF0-F702-4C43-80A4-A18AC4AD59C6-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-13 9:35 ` Maxime Ripard
2016-05-27 9:13 ` [PATCH v2 6/9] libfdt: Add max phandle retrieval function Maxime Ripard
2016-06-10 2:55 ` Stefan Agner
[not found] ` <1464340402-2249-7-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 15:13 ` Pantelis Antoniou
2016-05-27 9:13 ` [PATCH v2 7/9] libfdt: Add overlay application function Maxime Ripard
2016-06-10 3:38 ` Stefan Agner
[not found] ` <1464340402-2249-8-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 14:28 ` Pantelis Antoniou
[not found] ` <34997AD3-B621-4823-920E-22E4A6F0E0D1-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-13 9:51 ` Maxime Ripard
2016-06-14 0:25 ` David Gibson
[not found] ` <20160614002550.GA4882-RXTfZT5YzpxwFLYp8hBm2A@public.gmane.org>
2016-06-14 9:22 ` Pantelis Antoniou
[not found] ` <F0B62E6A-D5CE-4505-BC19-5EAB72A33ADE-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-15 3:14 ` David Gibson
2016-06-15 9:34 ` Pantelis Antoniou
[not found] ` <7E8A7CBD-D682-45E5-AD2C-19F137E5ED38-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-15 10:19 ` David Gibson
2016-06-15 10:23 ` Pantelis Antoniou
[not found] ` <F67FB562-88F6-4B3A-8952-ACA38AAC9256-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-06-15 14:49 ` Warner Losh
2016-05-27 9:13 ` [PATCH v2 8/9] cmd: fdt: add fdt overlay application subcommand Maxime Ripard
[not found] ` <1464340402-2249-9-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 3:45 ` Stefan Agner
2016-06-10 13:56 ` Pantelis Antoniou
2016-05-27 9:13 ` [PATCH v2 9/9] tests: Introduce DT overlay tests Maxime Ripard
[not found] ` <1464340402-2249-10-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-06-10 0:34 ` Simon Glass
2016-06-10 15:20 ` Pantelis Antoniou
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=f00eb3469391b1d3d473c227531cf7a7@agner.ch \
--to=stefan@agner.ch \
--cc=alex@nextthing.co \
--cc=devicetree-compiler@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=pantelis.antoniou@konsulko.com \
--cc=thomas.petazzoni@free-electrons.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).