From 49867e804543f64ca216653c3905d8022c31fc84 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 15 Nov 2024 16:19:12 -0700 Subject: 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 --- boot/bootdev-uclass.c | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) (limited to 'boot/bootdev-uclass.c') 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; -- cgit v1.2.3