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 <[email protected]>
---
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?
+
+ 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?
+
+ 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?
+
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
Best regards
Heinrich
+ */
+const char *bootflow_guess_label(const struct bootflow *bflow);
+
#endif