From 3058e283b885d80fbaaaaed6f597a068188be948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Thu, 20 Jan 2022 01:04:42 +0100 Subject: fdt_support: Add fdt_for_each_node_by_compatible() helper macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Stefan Roese Reviewed-by: Simon Glass --- board/Marvell/octeon_ebb7304/board.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'board/Marvell') 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 @@ static int get_lmac_fdt_node(const void *fdt, int search_node, int search_bgx, i 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 @@ static int get_mix_fdt_node(const void *fdt, int search_node, int search_index) 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; -- cgit v1.1