]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: Allow the bootdev to be optional in bootflows
authorSimon Glass <sjg@chromium.org>
Sat, 30 Jul 2022 21:52:23 +0000 (15:52 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 12 Aug 2022 12:17:11 +0000 (08:17 -0400)
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@chromium.org>
boot/bootdev-uclass.c
boot/bootflow.c
cmd/bootflow.c

index 5683006c73c6f6255377a79ca9ea19d12c544d01..13ac69eb392fd70822e4ddbbeafe472858d2b761 100644 (file)
@@ -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;
 }
index 24ba3c346602f04feacab104d0e76246717a406b..37bccb823a1405c9f9e21f4431a0d98ed6fb3a04 100644 (file)
@@ -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);
index af4b9c3732371a364a038c40caabef4aeca85b0f..47899245ee804a082dc90d51ccd2ca0ca241fb7b 100644 (file)
@@ -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);
 }