[PATCH 10/11] boot: build the imagemap pointers only when enabled
Simon Glass
sjg at chromium.org
Tue Oct 20 01:03:04 PDT 2026
Hi Daniel,
On 2026-10-14T08:38:38, Daniel Golle <daniel at makrotopia.org> wrote:
> boot: build the imagemap pointers only when enabled
>
> struct bootm_headers and struct bootm_info carry an imagemap pointer
> whatever the configuration, so every board pays for it with the feature
> off, and each use site has to spell out an IS_ENABLED() test beside the
> NULL check.
>
> Compile the two fields under CONFIG_IMAGEMAP and reach them through
> bootm_imagemap(), bootm_set_imagemap() and bootm_info_imagemap(), which
> fold to NULL and to nothing when it is off.
>
> Signed-off-by: Daniel Golle <daniel at makrotopia.org>
>
> boot/bootm.c | 28 ++++++++++++++--------------
> boot/image-fit.c | 12 ++++++------
> include/bootm.h | 17 +++++++++++++++++
> include/image.h | 31 +++++++++++++++++++++++++++++++
> 4 files changed, 68 insertions(+), 20 deletions(-)
> diff --git a/boot/image-fit.c b/boot/image-fit.c
> @@ -2246,11 +2246,11 @@ static int fit_image_load_storage(struct bootm_headers *images, const void *fit,
> !fit_image_get_load(fit, noffset, &img_load)) {
> dst = map_sysmem(img_load, data_sz);
>
> - mapped = imagemap_map_to(images->imagemap, data_off, data_sz,
> + mapped = imagemap_map_to(bootm_imagemap(images), data_off, data_sz,
> dst);
This runs to 83 columns once tabs expand. A local for the device would
bring it back under 80 and avoid the double call a few lines on in the
else branch.
> diff --git a/include/bootm.h b/include/bootm.h
> @@ -52,12 +52,29 @@ struct bootm_info {
> const char *conf_fdt;
> bool boot_progress;
> struct bootm_headers *images;
> +#if CONFIG_IS_ENABLED(IMAGEMAP)
> struct udevice *imagemap;
> +#endif
Please add a bootm_info_set_imagemap() alongside the getter. Without
it any future caller that wants to populate bmi->imagemap (the openwrt
bootmeth the cover letter mentions) has to spell the ifdef out itself,
which is the pattern this patch is retiring.
> diff --git a/include/bootm.h b/include/bootm.h
> @@ -52,12 +52,29 @@ struct bootm_info {
> +static inline struct udevice *bootm_info_imagemap(struct bootm_info *bmi)
> +{
> +#if CONFIG_IS_ENABLED(IMAGEMAP)
> + return bmi->imagemap;
> +#else
> + return NULL;
> +#endif
> +}
bootm_imagemap() in image.h guards on '!defined(USE_HOSTCC) &&
CONFIG_IS_ENABLED(IMAGEMAP)' but this one drops the USE_HOSTCC half.
tools/image-host.c pulls bootm.h in, so please keep the two guards in
step.
> diff --git a/boot/bootm.c b/boot/bootm.c
> @@ -1318,9 +1318,9 @@ int bootm_run_states(struct bootm_info *bmi, int states)
> /* Now run the OS! We hope this doesn't return */
> if (!ret && (states & BOOTM_STATE_OS_GO)) {
> /* Release storage backend before jumping - no return expected */
> - if (IS_ENABLED(CONFIG_IMAGEMAP) && images->imagemap) {
> - imagemap_cleanup(images->imagemap);
> - images->imagemap = NULL;
> + if (bootm_imagemap(images)) {
> + imagemap_cleanup(bootm_imagemap(images));
> + bootm_set_imagemap(images, NULL);
> }
The same cleanup block appears here and in the err: path just below,
so should be in a helper.
Regards,
Simon
More information about the openwrt-devel
mailing list