summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2022-01-20 03:04:42 +0300
committerStefan Roese <sr@denx.de>2022-01-20 13:35:29 +0300
commit3058e283b885d80fbaaaaed6f597a068188be948 (patch)
tree3acad866dc7b75435b3bf1972ab7323257b707cc /board
parent068415eadefbbc81f14d4ce61fcf7a7eb39650d4 (diff)
downloadu-boot-3058e283b885d80fbaaaaed6f597a068188be948.tar.xz
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>
Diffstat (limited to 'board')
-rw-r--r--board/Marvell/octeon_ebb7304/board.c9
-rw-r--r--board/congatec/cgtqmx8/spl.c8
-rw-r--r--board/freescale/lx2160a/lx2160a.c5
3 files changed, 7 insertions, 15 deletions
diff --git a/board/Marvell/octeon_ebb7304/board.c b/board/Marvell/octeon_ebb7304/board.c
index c6c7c13483..5fd84b260b 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;
diff --git a/board/congatec/cgtqmx8/spl.c b/board/congatec/cgtqmx8/spl.c
index 37b7221c52..dea34e4dc6 100644
--- a/board/congatec/cgtqmx8/spl.c
+++ b/board/congatec/cgtqmx8/spl.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
+#include <fdt_support.h>
#include <init.h>
#include <log.h>
#include <spl.h>
@@ -29,13 +30,10 @@ void spl_board_init(void)
continue;
}
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd");
- while (offset != -FDT_ERR_NOTFOUND) {
+ fdt_for_each_node_by_compatible(offset, gd->fdt_blob, -1,
+ "nxp,imx8-pd")
lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
NULL, NULL, true);
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
- "nxp,imx8-pd");
- }
uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev);
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index bda665624d..c9835f9299 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -123,8 +123,7 @@ int board_fix_fdt(void *fdt)
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 @@ int board_fix_fdt(void *fdt)
}
fdt_setprop(fdt, off, "reg-names", reg_names, names_len);
- off = fdt_node_offset_by_compatible(fdt, off,
- "fsl,lx2160a-pcie");
}
return 0;