[PATCH v5 2/4] boot: Move obtaining the label into a common file
Simon Glass
sjg at chromium.org
Sun Oct 12 08:43:54 CEST 2025
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;
+
+ if (bflow->dev) {
+ struct udevice *media = dev_get_parent(bflow->dev);
+
+ 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
--
2.43.0
More information about the U-Boot
mailing list