fdt_support: Add fdt_for_each_node_by_compatible() helper macro
Add macro fdt_for_each_node_by_compatible() to allow iterating over
fdt nodes by compatible string.
Convert various usages of
off = fdt_node_offset_by_compatible(fdt, start, compat);
while (off > 0) {
code();
off = fdt_node_offset_by_compatible(fdt, off, compat);
}
and similar, to
fdt_for_each_node_by_compatible(off, fdt, start, compat)
code();
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/video/meson/simplefb_common.c b/drivers/video/meson/simplefb_common.c
index 8178232..c8b5af5 100644
--- a/drivers/video/meson/simplefb_common.c
+++ b/drivers/video/meson/simplefb_common.c
@@ -7,22 +7,19 @@
* (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io>
*/
-#include <fdtdec.h>
+#include <fdt_support.h>
int meson_simplefb_fdt_match(void *blob, const char *pipeline)
{
int offset, ret;
/* Find a prefilled simpefb node, matching out pipeline config */
- offset = fdt_node_offset_by_compatible(blob, -1,
- "amlogic,simple-framebuffer");
- while (offset >= 0) {
+ fdt_for_each_node_by_compatible(offset, blob, -1,
+ "amlogic,simple-framebuffer") {
ret = fdt_stringlist_search(blob, offset, "amlogic,pipeline",
pipeline);
if (ret == 0)
break;
- offset = fdt_node_offset_by_compatible(blob, offset,
- "amlogic,simple-framebuffer");
}
return offset;