From d5f9415b04846661522141ea428f74e3c618fa9e Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Sat, 19 Dec 2015 00:18:34 +0000 Subject: 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 Signed-off-by: Sascha Hauer --- include/of.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/of.h') 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) { -- cgit v1.2.3