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/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index bda6656..c9835f9 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -123,8 +123,7 @@
if (IS_SVR_REV(get_svr(), 1, 0))
return 0;
- off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie");
- while (off != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(off, fdt, -1, "fsl,lx2160a-pcie") {
fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie",
strlen("fsl,ls-pcie") + 1);
@@ -166,8 +165,6 @@
}
fdt_setprop(fdt, off, "reg-names", reg_names, names_len);
- off = fdt_node_offset_by_compatible(fdt, off,
- "fsl,lx2160a-pcie");
}
return 0;