aboutsummaryrefslogtreecommitdiffstats
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-11-15 16:19:11 -0700
committerTom Rini <trini@konsulko.com>2025-01-15 08:48:42 -0600
commit6a3eb84b18333eb4beb7e660fa9ae8ccff07b0c4 (patch)
treeb249db2403152ebb44f6b29b57752b392671a61b /boot
parent529f92677defa4788ef0d43229caa5771be041a0 (diff)
downloadu-boot-6a3eb84b18333eb4beb7e660fa9ae8ccff07b0c4.tar.gz
bootstd: Drop the bootdev-specific list of bootflows
This list is only used by two functions, which can be updated to iterate through the global list. Take this approach, which allows the bootdev list to be dropped. Overall this makes the code slightly more complicated, but will allow moving the bootflow list into an alist Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot')
-rw-r--r--boot/bootdev-uclass.c61
-rw-r--r--boot/bootflow.c2
-rw-r--r--boot/bootstd-uclass.c17
3 files changed, 46 insertions, 34 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 26b003427ec..81adfb4cfb7 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,30 +32,57 @@ enum {
BOOT_TARGETS_MAX_LEN = 100,
};
+struct bootflow *bootdev_next_bootflow_(struct bootstd_priv *std,
+ struct udevice *dev,
+ struct bootflow *prev)
+{
+ struct bootflow *bflow = prev;
+
+ if (bflow) {
+ if (list_is_last(&bflow->glob_node, &std->glob_head))
+ return NULL;
+ bflow = list_entry(bflow->glob_node.next, struct bootflow,
+ glob_node);
+ } else {
+ if (list_empty(&std->glob_head))
+ return NULL;
+
+ bflow = list_first_entry(&std->glob_head, struct bootflow,
+ glob_node);
+ }
+
+ while (bflow->dev != dev) {
+ if (list_is_last(&bflow->glob_node, &std->glob_head))
+ return NULL;
+ bflow = list_entry(bflow->glob_node.next, struct bootflow,
+ glob_node);
+ }
+
+ return bflow;
+}
+
int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
{
- struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+ struct bootstd_priv *std = bootstd_try_priv();
+ struct bootflow *bflow;
- if (list_empty(&ucp->bootflow_head))
+ bflow = bootdev_next_bootflow_(std, dev, NULL);
+ if (!bflow)
return -ENOENT;
-
- *bflowp = list_first_entry(&ucp->bootflow_head, struct bootflow,
- bm_node);
+ *bflowp = bflow;
return 0;
}
int bootdev_next_bootflow(struct bootflow **bflowp)
{
- struct bootflow *bflow = *bflowp;
- struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
-
- *bflowp = NULL;
+ struct bootstd_priv *std = bootstd_try_priv();
+ struct bootflow *bflow;
- if (list_is_last(&bflow->bm_node, &ucp->bootflow_head))
+ bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp);
+ if (!bflow)
return -ENOENT;
-
- *bflowp = list_entry(bflow->bm_node.next, struct bootflow, bm_node);
+ *bflowp = bflow;
return 0;
}
@@ -911,15 +938,6 @@ void bootdev_list_hunters(struct bootstd_priv *std)
printf("(total hunters: %d)\n", n_ent);
}
-static int bootdev_post_bind(struct udevice *dev)
-{
- struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
-
- INIT_LIST_HEAD(&ucp->bootflow_head);
-
- return 0;
-}
-
static int bootdev_pre_unbind(struct udevice *dev)
{
int ret;
@@ -936,6 +954,5 @@ UCLASS_DRIVER(bootdev) = {
.name = "bootdev",
.flags = DM_UC_FLAG_SEQ_ALIAS,
.per_device_plat_auto = sizeof(struct bootdev_uc_plat),
- .post_bind = bootdev_post_bind,
.pre_unbind = bootdev_pre_unbind,
};
diff --git a/boot/bootflow.c b/boot/bootflow.c
index d8807eb109d..804809dc100 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -476,8 +476,6 @@ void bootflow_free(struct bootflow *bflow)
void bootflow_remove(struct bootflow *bflow)
{
- if (bflow->dev)
- list_del(&bflow->bm_node);
list_del(&bflow->glob_node);
bootflow_free(bflow);
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
index b2f80808c85..91e90bdf43c 100644
--- a/boot/bootstd-uclass.c
+++ b/boot/bootstd-uclass.c
@@ -77,25 +77,22 @@ int bootstd_add_bootflow(struct bootflow *bflow)
memcpy(new, bflow, sizeof(*bflow));
list_add_tail(&new->glob_node, &std->glob_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;
}
int bootstd_clear_bootflows_for_bootdev(struct udevice *dev)
{
- struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+ struct bootstd_priv *std = bootstd_try_priv();
- while (!list_empty(&ucp->bootflow_head)) {
+ if (std) {
struct bootflow *bflow;
+ struct list_head *pos;
- bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
- bm_node);
- bootflow_remove(bflow);
+ list_for_each(pos, &std->glob_head) {
+ bflow = list_entry(pos, struct bootflow, glob_node);
+ bootflow_remove(bflow);
+ }
}
return 0;