U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Simon Glass <sjg@chromium.org>, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>,
	Peter Robinson <pbrobinson@gmail.com>,
	Simon Glass <sjg@chromium.org>,
	Andrew Goodbody <andrew.goodbody@linaro.org>,
	Guillaume La Roque <glaroque@baylibre.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Jerome Forissier <jerome.forissier@linaro.org>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Maximilian Brune <maximilian.brune@9elements.com>,
	Moritz Fischer <moritzf@google.com>
Subject: Re: [PATCH v4 2/4] boot: Move obtaining the label into a common file
Date: Thu, 09 Oct 2025 15:13:07 +0200	[thread overview]
Message-ID: <87zfa0uskc.fsf@kernel.org> (raw)
In-Reply-To: <20251009092959.260121-3-sjg@chromium.org>

Hi Simon,

Thank you for the patch.

On Thu, Oct 09, 2025 at 03:29, Simon Glass <sjg@chromium.org> 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.
>
> Use 'usb' instead of 'usb_mass_storage' for usb so that it fits in the
> column space.
>
> This updates the output from 'bootflow list'.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>
> (no changes since v1)
>
>  boot/bootflow.c      | 19 +++++++++++++++++++
>  cmd/bootflow.c       |  8 +++++---
>  include/bootflow.h   |  8 ++++++++
>  test/boot/bootflow.c |  2 +-
>  4 files changed, 33 insertions(+), 4 deletions(-)
>
> diff --git a/boot/bootflow.c b/boot/bootflow.c
> index 15df7069209..78df09f369d 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,21 @@ 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;
> +
> +	if (bflow->dev) {
> +		struct udevice *media = dev_get_parent(bflow->dev);
> +
> +		if (device_get_uclass_id(media) == UCLASS_MASS_STORAGE)
> +			name = "usb";
> +		else
> +			name = dev_get_uclass_name(media);
> +	}
> +	if (!name)
> +		name = "(none)";
> +
> +	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);
> +
>  	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.
> + */
> +const char *bootflow_guess_label(const struct bootflow *bflow);
> +
>  #endif
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index 7cd83dc7443..73fe3d34d0f 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -1301,7 +1301,7 @@ static int bootflow_efi(struct unit_test_state *uts)
>  	ut_assert_nextlinen("---");
>  	ut_assert_nextlinen("  0  extlinux");
>  	ut_assert_nextlinen(
> -		"  1  efi          ready   usb_mass_    1  usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI");
> +		"  1  efi          ready   usb          1  usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI");
>  	ut_assert_nextlinen("---");
>  	ut_assert_skip_to_line("(2 bootflows, 2 valid)");
>  	ut_assert_console_end();
> -- 
> 2.43.0

  reply	other threads:[~2025-10-09 13:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09  9:29 [PATCH v4 0/4] boot: Precursor series for global bootmeths Simon Glass
2025-10-09  9:29 ` [PATCH v4 1/4] boot: Improve comments related to " Simon Glass
2025-10-09 12:52   ` Mattijs Korpershoek
2025-10-09 18:34   ` Sam Protsenko
2025-10-09  9:29 ` [PATCH v4 2/4] boot: Move obtaining the label into a common file Simon Glass
2025-10-09 13:13   ` Mattijs Korpershoek [this message]
2025-10-09 17:24   ` Tom Rini
2025-10-10 10:35     ` Simon Glass
2025-10-10 14:11       ` Mattijs Korpershoek
2025-10-10 14:39         ` Tom Rini
2025-10-11  7:21           ` Simon Glass
2025-10-11 16:24             ` Tom Rini
2025-10-09  9:29 ` [PATCH v4 3/4] boot: Add more debugging to iter_incr() Simon Glass
2025-10-09 17:30   ` Tom Rini
2025-10-10 10:36     ` Simon Glass
2025-10-10 14:35       ` Tom Rini
2025-10-11  7:19         ` Simon Glass
2025-10-13 14:15           ` Tom Rini
2025-10-13 15:12             ` Simon Glass
2025-10-13 16:57               ` Tom Rini
2025-10-09  9:29 ` [PATCH v4 4/4] boot: Move preparing bootdev into a function Simon Glass
2025-10-09 17:35   ` Tom Rini
2025-10-10 10:36     ` Simon Glass
2025-10-10 14:38       ` Tom Rini
2025-10-11  7:20         ` Simon Glass
2025-10-11 16:45           ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfa0uskc.fsf@kernel.org \
    --to=mkorpershoek@kernel.org \
    --cc=andrew.goodbody@linaro.org \
    --cc=glaroque@baylibre.com \
    --cc=jerome.forissier@linaro.org \
    --cc=maximilian.brune@9elements.com \
    --cc=moritzf@google.com \
    --cc=pbrobinson@gmail.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox