[PATCH 12/39] bootm: Allow building bootm.c without CONFIG_SYS_BOOTM_LEN

Simon Glass sjg at chromium.org
Wed Nov 20 14:37:34 CET 2024


Hi Ilias,

On Wed, 20 Nov 2024 at 03:56, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> Hi Simon,
>
> On Tue, 19 Nov 2024 at 15:19, Simon Glass <sjg at chromium.org> wrote:
> >
> > This code cannot be compiled by boards which don't have this option. Add
> > an accessor in the header file to avoid another #ifdef
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> >  boot/bootm.c    | 8 ++++----
> >  include/bootm.h | 8 ++++++++
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/boot/bootm.c b/boot/bootm.c
> > index 16a43d519a8..0a1040ef923 100644
> > --- a/boot/bootm.c
> > +++ b/boot/bootm.c
> > @@ -633,11 +633,11 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
> >         load_buf = map_sysmem(load, 0);
> >         image_buf = map_sysmem(os.image_start, image_len);
> >         err = image_decomp(os.comp, load, os.image_start, os.type,
> > -                          load_buf, image_buf, image_len,
> > -                          CONFIG_SYS_BOOTM_LEN, &load_end);
> > +                          load_buf, image_buf, image_len, bootm_len(),
> > +                          &load_end);
> >         if (err) {
> > -               err = handle_decomp_error(os.comp, load_end - load,
> > -                                         CONFIG_SYS_BOOTM_LEN, err);
> > +               err = handle_decomp_error(os.comp, load_end - load, bootm_len(),
> > +                                         err);
> >                 bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
> >                 return err;
> >         }
> > diff --git a/include/bootm.h b/include/bootm.h
> > index c471615b08c..d174f18ac18 100644
> > --- a/include/bootm.h
> > +++ b/include/bootm.h
> > @@ -89,6 +89,14 @@ struct bootm_info {
> >  #define bootm_x86_set(_bmi, _field, _val)
> >  #endif
> >
> > +static inline ulong bootm_len(void)
> > +{
> > +#ifdef CONFIG_SYS_BOOTM_LEN
> > +       return CONFIG_SYS_BOOTM_LEN;
> > +#endif
> > +       return 0;
> > +}
>
> Do we really need a function for this?
> Why don't you
> #ifdef CONFIG_SYS_BOOTM_LEN
> #define SYS_BOOTM_LEN CONFIG_SYS_BOOTM_LEN
> #else
> #define SYS_BOOTM_LEN 0
> #endif

Yes, we could. Just trying to avoid #ifdefs in the C files and provide
a way to improve this logic later...IMO using this value when it is
not defined should be an error, but we cannot do that in the
tools-only build, without yet more refactoring.

Regards,
Simon


More information about the U-Boot mailing list