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>
This commit is contained in:
Simon Glass
2024-11-15 16:19:12 -07:00
committed by Tom Rini
parent 6a3eb84b18
commit 49867e8045
7 changed files with 51 additions and 77 deletions

View File

@@ -55,11 +55,10 @@ int bootflow_first_glob(struct bootflow **bflowp)
if (ret)
return ret;
if (list_empty(&std->glob_head))
if (!std->bootflows.count)
return -ENOENT;
*bflowp = list_first_entry(&std->glob_head, struct bootflow,
glob_node);
*bflowp = alist_getw(&std->bootflows, 0, struct bootflow);
return 0;
}
@@ -67,20 +66,16 @@ int bootflow_first_glob(struct bootflow **bflowp)
int bootflow_next_glob(struct bootflow **bflowp)
{
struct bootstd_priv *std;
struct bootflow *bflow = *bflowp;
int ret;
ret = bootstd_get_priv(&std);
if (ret)
return ret;
*bflowp = NULL;
if (list_is_last(&bflow->glob_node, &std->glob_head))
*bflowp = alist_nextw(&std->bootflows, *bflowp);
if (!*bflowp)
return -ENOENT;
*bflowp = list_entry(bflow->glob_node.next, struct bootflow, glob_node);
return 0;
}
@@ -476,10 +471,7 @@ void bootflow_free(struct bootflow *bflow)
void bootflow_remove(struct bootflow *bflow)
{
list_del(&bflow->glob_node);
bootflow_free(bflow);
free(bflow);
}
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)