mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: barebox <barebox@lists.infradead.org>
Subject: [PATCH 2/2] of: Add of_property_for_each_phandle() iterator
Date: Sat, 19 Dec 2015 00:18:34 +0000	[thread overview]
Message-ID: <1450484315.26955.230.camel@rtred1test09.kymeta.local> (raw)
In-Reply-To: <1450484040.26955.228.camel@rtred1test09.kymeta.local>

This is like of_property_for_each_{string,u32} but loops over a list
of phandles instead of strings or ints.

Returns the node the handle points to as that's generally more useful
than the handle value itself.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
 include/of.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/of.h b/include/of.h
index e65a8e8..18c92d7 100644
--- a/include/of.h
+++ b/include/of.h
@@ -736,6 +736,17 @@ static inline int of_property_read_u32(const struct device_node *np,
 		s;						\
 		s = of_prop_next_string(prop, s))
 
+/*
+ * struct device_node *n;
+ *
+ * of_property_for_each_phandle(np, root, "propname", n)
+ *         printk("phandle points to: %s\n", n->full_name);
+ */
+#define of_property_for_each_phandle(np, root, propname, n)	\
+	for (int _i = 0; 					\
+	     (n = of_parse_phandle_from(np, root, propname, _i));\
+	     _i++)
+
 static inline int of_property_write_u8(struct device_node *np,
 				       const char *propname, u8 value)
 {
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-12-19  0:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-19  0:13 [PATCH 1/2] of: Add for_each_compatible_node_from iterator Trent Piepho
2015-12-19  0:18 ` Trent Piepho [this message]
2016-01-04  8:32 ` Sascha Hauer
2016-01-04 19:01   ` [PATCH 1/2] OF: fix typo in for_each_compatible_node() Trent Piepho
2016-01-05  7:49     ` Sascha Hauer
2016-01-04 19:02   ` [PATCH 2/2] OF: Fix fixups to fix Linux DT instead of Barebox DT Trent Piepho
2016-01-05  7:50     ` Sascha Hauer
2016-01-04 19:07   ` [PATCH 1/2] of: Add for_each_compatible_node_from iterator Trent Piepho
2016-01-05  7:58     ` Sascha Hauer
2016-01-05  8:05       ` Yegor Yefremov
2016-01-05  8:20         ` Sascha Hauer
2016-01-05  8:30           ` Yegor Yefremov
2016-01-05 18:58       ` Trent Piepho
2016-01-07  7:34         ` Sascha Hauer

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=1450484315.26955.230.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox