diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2022-01-20 01:04:42 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2022-01-20 11:35:29 +0100 |
commit | 3058e283b885d80fbaaaaed6f597a068188be948 (patch) | |
tree | 3acad866dc7b75435b3bf1972ab7323257b707cc /include/fdt_support.h | |
parent | 068415eadefbbc81f14d4ce61fcf7a7eb39650d4 (diff) | |
download | u-boot-3058e283b885d80fbaaaaed6f597a068188be948.tar.gz |
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 'include/fdt_support.h')
-rw-r--r-- | include/fdt_support.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/fdt_support.h b/include/fdt_support.h index 8ec461af6c3..852040f66f4 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -289,6 +289,12 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat, phys_addr_t compat_off); int fdt_node_offset_by_pathf(void *blob, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + +#define fdt_for_each_node_by_compatible(node, fdt, start, compat) \ + for (node = fdt_node_offset_by_compatible(fdt, start, compat); \ + node >= 0; \ + node = fdt_node_offset_by_compatible(fdt, node, compat)) + int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle); unsigned int fdt_create_phandle(void *fdt, int nodeoffset); unsigned int fdt_create_phandle_by_compatible(void *fdt, const char *compat); |