[PATCH v1 3/3] boot/fit: use fdt_for_each_subnode() in image-fit.c
Simon Glass
sjg at chromium.org
Mon May 11 15:30:04 CEST 2026
On 2026-05-08T21:31:58, Aristo Chen <aristo.chen at canonical.com> wrote:
> boot/fit: use fdt_for_each_subnode() in image-fit.c
>
> Replace the verbose fdt_next_node() + ndepth pattern with the
> fdt_for_each_subnode() macro at all seven sites in boot/image-fit.c
> where the loop only ever processes direct children. The macro is
> already defined in <linux/libfdt.h> and used in boot/image-fit-sig.c,
> so this brings image-fit.c in line with the rest of the FIT code.
>
> The conversions are equivalence-preserving:
>
> - fit_get_subimage_count(): the depth-1 filter and the macro are
> both restricted to direct children.
> - fit_conf_print(): the parameter is named noffset, so the loop
> now uses sub_noffset to keep the parent reference stable.
> - fit_print_contents(): the count reset that lived inside the for
> initialiser is moved out as an explicit assignment before each
> loop, so the second loop still starts from zero.
> - fit_image_print(): straightforward replacement.
> - fit_all_image_verify(): same shape as the print loops, with the
> count reset moved out as an explicit assignment before the loop.
> - fit_conf_find_compat(): the body's "if (ndepth > 1) continue"
> guard is redundant once the macro is in use, and is dropped.
>
> No behaviour changes outside of these mechanical reductions. Local
> ndepth declarations that are no longer referenced are removed.
>
> Signed-off-by: Aristo Chen <aristo.chen at canonical.com>
>
> boot/image-fit.c | 107 ++++++++++++++-----------------------------------------
> 1 file changed, 27 insertions(+), 80 deletions(-)
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list