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/Marvell/octeon_ebb7304/board.c b/board/Marvell/octeon_ebb7304/board.c
index c6c7c13..5fd84b2 100644
--- a/board/Marvell/octeon_ebb7304/board.c
+++ b/board/Marvell/octeon_ebb7304/board.c
@@ -103,9 +103,7 @@
 	int parent;
 
 	/* Iterate through all bgx ports */
-	node = -1;
-	while ((node = fdt_node_offset_by_compatible((void *)fdt, node,
-						     compat)) >= 0) {
+	fdt_for_each_node_by_compatible(node, (void *)fdt, -1, compat) {
 		/* Get the node and bgx from the physical address */
 		parent = fdt_parent_offset(fdt, node);
 		reg = fdt_getprop(fdt, parent, "reg", &len);
@@ -146,9 +144,8 @@
 	int node;
 
 	/* Iterate through all the mix fdt nodes */
-	node = -1;
-	while ((node = fdt_node_offset_by_compatible((void *)fdt, node,
-						     "cavium,octeon-7890-mix")) >= 0) {
+	fdt_for_each_node_by_compatible(node, (void *)fdt, -1,
+					"cavium,octeon-7890-mix") {
 		int parent;
 		int len;
 		const char *name;