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/net/fm/fdt.c b/drivers/net/fm/fdt.c
index 3855d7d..9828753 100644
--- a/drivers/net/fm/fdt.c
+++ b/drivers/net/fm/fdt.c
@@ -115,8 +115,7 @@
}
/* Find all other Fman nodes and point them to the firmware node. */
- while ((fmnode = fdt_node_offset_by_compatible(blob, fmnode,
- "fsl,fman")) > 0) {
+ fdt_for_each_node_by_compatible(fmnode, blob, fmnode, "fsl,fman") {
rc = fdt_setprop_cell(blob, fmnode, "fsl,firmware-phandle",
phandle);
if (rc < 0) {