summaryrefslogtreecommitdiffstats
path: root/include/of.h
diff options
context:
space:
mode:
authorTrent Piepho <tpiepho@kymetacorp.com>2015-12-19 00:18:34 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-08 08:30:56 +0100
commitd5f9415b04846661522141ea428f74e3c618fa9e (patch)
tree984ee9003ddd993f8f1fe03a22fac34d1d3d0dfe /include/of.h
parent3a51749e2e7572d5b145bb110298372a82b16e41 (diff)
downloadbarebox-d5f9415b04846661522141ea428f74e3c618fa9e.tar.gz
barebox-d5f9415b04846661522141ea428f74e3c618fa9e.tar.xz
of: Add of_property_for_each_phandle() iterator
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/of.h')
-rw-r--r--include/of.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/of.h b/include/of.h
index 82faf25d62..75cc3c11c1 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)
{