[PATCH v5 2/4] boot: Move obtaining the label into a common file

Simon Glass sjg at chromium.org
Mon Oct 13 15:41:22 CEST 2025


Hi Heinrich,

On Mon, 13 Oct 2025 at 11:01, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 10/12/25 08:43, Simon Glass wrote:
> > The 'bootflow list' command supports looking at the EFI device-path when
> > available. Move this piece into a common function so it can be used
> > elsewhere.
> >
> > This updates the output from 'bootflow list'.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> > ---
> >
> > Changes in v5:
> > - Move 'usb' rename into a separate patch
> >
> >   boot/bootflow.c    | 16 ++++++++++++++++
> >   cmd/bootflow.c     |  8 +++++---
> >   include/bootflow.h |  8 ++++++++
> >   3 files changed, 29 insertions(+), 3 deletions(-)
> >
> > diff --git a/boot/bootflow.c b/boot/bootflow.c
> > index 15df7069209..6485d473d69 100644
> > --- a/boot/bootflow.c
> > +++ b/boot/bootflow.c
> > @@ -11,6 +11,7 @@
> >   #include <bootmeth.h>
> >   #include <bootstd.h>
> >   #include <dm.h>
> > +#include <efi_device_path.h>
> >   #include <env_internal.h>
> >   #include <malloc.h>
> >   #include <serial.h>
> > @@ -1010,3 +1011,18 @@ int bootflow_get_seq(const struct bootflow *bflow)
> >
> >       return alist_calc_index(&std->bootflows, bflow);
> >   }
> > +
> > +const char *bootflow_guess_label(const struct bootflow *bflow)
> > +{
> > +     const char *name = NULL;
>
> Why would you not return bootflow->name if it is allocated?

This is intended to show the label of the bootdev which produced the
bootflow. If you look below you can see that the bootflow name is
already shown, so we don't want to show it twice.

>
> > +
> > +     if (bflow->dev) {
> > +             struct udevice *media = dev_get_parent(bflow->dev);
> > +
> > +             name = dev_get_uclass_name(media);
> > +     }
> > +     if (!name)
> > +             name = "(none)";
>
> Label "(none)" makes no sense to bootflows created for BOOTMETHF_GLOBAL.
> Can't we return a string for the bootmeth instead?

Similarly, the bootmeth name is already shown. See below.

>
> > +
> > +     return name;
> > +}
> > diff --git a/cmd/bootflow.c b/cmd/bootflow.c
> > index 551dffbb8b8..5b803d4ace5 100644
> > --- a/cmd/bootflow.c
> > +++ b/cmd/bootflow.c
> > @@ -70,10 +70,12 @@ static void report_bootflow_err(struct bootflow *bflow, int err)
> >    */
> >   static void show_bootflow(int index, struct bootflow *bflow, bool errors)
> >   {
> > +     const char *name = bootflow_guess_label(bflow);
>
> Why would we guess a name if bflow->name != NULL?

It isn't the name we are trying to guess, it is the bootdev. We are
trying to show a friendly name for the bootdev.

>
> > +
> >       printf("%3x  %-11s  %-6s  %-9.9s %4x  %-25.25s %s\n", index,
> > -            bflow->method->name, bootflow_state_get_name(bflow->state),
> > -            bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
> > -            "(none)", bflow->part, bflow->name, bflow->fname ?: "");
> > +            bflow->method ? bflow->method->name : "(none)",
> > +            bootflow_state_get_name(bflow->state), name, bflow->part,
> > +            bflow->name, bflow->fname ?: "");
> >       if (errors)
> >               report_bootflow_err(bflow, bflow->err);
> >   }
> > diff --git a/include/bootflow.h b/include/bootflow.h
> > index 2ef6eb25cf5..657e3731f11 100644
> > --- a/include/bootflow.h
> > +++ b/include/bootflow.h
> > @@ -692,4 +692,12 @@ int bootflow_menu_start(struct bootstd_priv *std, bool text_mode,
> >    */
> >   int bootflow_menu_poll(struct expo *exp, int *seqp);
> >
> > +/**
> > + * bootflow_guess_label() - Produce a plausible label for a bootflow
> > + *
> > + * This uses the uclass name or EFI device-path to come up with a useful label
> > + * for display to the user. Ideally it will say "mmc", "usb", nvme", etc.
>
> Please, describe the fallback.
>
> The documentation is comprehensible but unfortunately incomplete for
> what we want to generate in doc/api
>
> Please, add '@bootflow:', 'Return:'.
> cf.
> https://www.kernel.org/doc/html/v4.16/doc-guide/kernel-doc.html#function-documentation
>

OK


> Best regards
>
> Heinrich
>
> > + */
> > +const char *bootflow_guess_label(const struct bootflow *bflow);
> > +
> >   #endif
>

Regards,
Simon


More information about the U-Boot mailing list