[PATCH v2 21/35] bootstd: Allow the bootdev to be optional in bootflows
Simon Glass
sjg at chromium.org
Sat Jul 30 23:52:23 CEST 2022
With global bootmeths we want to scan without a bootdev. Update the logic
to allow this.
Change the bootflow command to show the bootdev only when valid.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
boot/bootdev-uclass.c | 7 +++++--
boot/bootflow.c | 3 ++-
cmd/bootflow.c | 4 ++--
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 5683006c73c..13ac69eb392 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -36,7 +36,6 @@ enum {
int bootdev_add_bootflow(struct bootflow *bflow)
{
- struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
struct bootstd_priv *std;
struct bootflow *new;
int ret;
@@ -52,7 +51,11 @@ int bootdev_add_bootflow(struct bootflow *bflow)
memcpy(new, bflow, sizeof(*bflow));
list_add_tail(&new->glob_node, &std->glob_head);
- list_add_tail(&new->bm_node, &ucp->bootflow_head);
+ if (bflow->dev) {
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
+
+ list_add_tail(&new->bm_node, &ucp->bootflow_head);
+ }
return 0;
}
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 24ba3c34660..37bccb823a1 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -307,7 +307,8 @@ void bootflow_free(struct bootflow *bflow)
void bootflow_remove(struct bootflow *bflow)
{
- list_del(&bflow->bm_node);
+ if (bflow->dev)
+ list_del(&bflow->bm_node);
list_del(&bflow->glob_node);
bootflow_free(bflow);
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index af4b9c37323..47899245ee8 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -69,8 +69,8 @@ static void show_bootflow(int index, struct bootflow *bflow, bool errors)
{
printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
bflow->method->name, bootflow_state_get_name(bflow->state),
- dev_get_uclass_name(dev_get_parent(bflow->dev)), bflow->part,
- bflow->name, bflow->fname);
+ bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
+ "(none)", bflow->part, bflow->name, bflow->fname);
if (errors)
report_bootflow_err(bflow, bflow->err);
}
--
2.37.1.455.g008518b4e5-goog
More information about the U-Boot
mailing list