mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] of: Add for_each_compatible_node_from iterator
@ 2015-12-19  0:13 Trent Piepho
  2015-12-19  0:18 ` [PATCH 2/2] of: Add of_property_for_each_phandle() iterator Trent Piepho
  2016-01-04  8:32 ` [PATCH 1/2] of: Add for_each_compatible_node_from iterator Sascha Hauer
  0 siblings, 2 replies; 14+ messages in thread
From: Trent Piepho @ 2015-12-19  0:13 UTC (permalink / raw)
  To: barebox

The existing iterator for_each_compatible_node() searches for each
compatible node starting from the root of the loaded device tree.
This means it only works on the barebox device tree and not the tree
to be passed to the Linux kernel, which is what an of_fixup would
probably want to use.

This adds for_each_compatible_node_from(), which takes an additional
parameter of a root to search from.  This could be the device tree to
be used for the kernel.  It could also be used to search just a
subtree.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---

It's possible the fixups in cm_cogent_fixup() and hb_fixup() should
be using this.  It's not clear to me if they want to modify the barebox
device tree or the Linux device tree or both.

 include/of.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/of.h b/include/of.h
index e60fe89..e65a8e8 100644
--- a/include/of.h
+++ b/include/of.h
@@ -641,9 +641,13 @@ static inline struct device_node *of_find_node_by_path_or_alias(
 #define for_each_node_by_name_from(dn, root, name) \
 	for (dn = of_find_node_by_name(root, name); dn; \
 	     dn = of_find_node_by_name(dn, name))
-#define for_each_compatible_node(dn, type, compatible) \
-	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
+/* Iterate over compatible nodes starting from given root */
+#define for_each_compatible_node_from(dn, root, type, compatible) \
+	for (dn = of_find_compatible_node(root, type, compatible); dn; \
 	     dn = of_find_compatible_node(dn, type, compatible))
+/* Iterate over compatible nodes in default device tree */
+#define for_each_compatible_node(dn, type, compatible) \
+        for_each_compatible_node_from(dn, NULL, type, compatible
 static inline struct device_node *of_find_matching_node(
 	struct device_node *from,
 	const struct of_device_id *matches)
-- 
1.8.3.1


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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-01-07  7:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-19  0:13 [PATCH 1/2] of: Add for_each_compatible_node_from iterator Trent Piepho
2015-12-19  0:18 ` [PATCH 2/2] of: Add of_property_for_each_phandle() iterator Trent Piepho
2016-01-04  8:32 ` [PATCH 1/2] of: Add for_each_compatible_node_from iterator 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox