[PATCH 2/2] of: Add of_property_for_each_phandle() iterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux