summaryrefslogtreecommitdiff
path: root/boot/bootdev-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-11-15 16:19:12 -0700
committerTom Rini <trini@konsulko.com>2025-01-15 08:48:42 -0600
commit49867e804543f64ca216653c3905d8022c31fc84 (patch)
tree8588bae07829c92ab693f0c1198ff4ccdc5afe39 /boot/bootdev-uclass.c
parent6a3eb84b18333eb4beb7e660fa9ae8ccff07b0c4 (diff)
bootstd: Move the bootflow list into an alist
Use an alist for this data structure as it is somewhat simpler to manage. This means that bootstd holds a simple list of bootflow structs and can drop it at will, without chasing down lists. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootdev-uclass.c')
-rw-r--r--boot/bootdev-uclass.c47
1 files changed, 14 insertions, 33 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 81adfb4cfb7..a4e1d79ec9b 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -32,41 +32,17 @@ 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 bootstd_priv *std = bootstd_try_priv();
+ struct bootstd_priv *std;
struct bootflow *bflow;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return log_msg_ret("bff", ret);
- bflow = bootdev_next_bootflow_(std, dev, NULL);
+ bflow = alist_getw(&std->bootflows, 0, struct bootflow);
if (!bflow)
return -ENOENT;
*bflowp = bflow;
@@ -76,10 +52,15 @@ int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
int bootdev_next_bootflow(struct bootflow **bflowp)
{
- struct bootstd_priv *std = bootstd_try_priv();
+ struct bootstd_priv *std;
struct bootflow *bflow;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return log_msg_ret("bff", ret);
- bflow = bootdev_next_bootflow_(std, (*bflowp)->dev, *bflowp);
+ bflow = alist_nextw(&std->bootflows, *bflowp);
if (!bflow)
return -ENOENT;
*bflowp = bflow;