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 <[email protected]> --- (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

