From 3d6531803e1cdc4c6976dae3c92220daba57f148 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 26 Sep 2023 08:14:51 -0600 Subject: bloblist: Support initing from multiple places Typically the bloblist is set up after the devicetree is present. This makes sense because bloblist may use malloc() to allocate the space it needs. However sometimes the devicetree itself may be present in the bloblist. In that case it is at a known location in memory so we can init the bloblist very early, before devicetree. Add a flag to indicate whether the bloblist has been inited. Add a function to init it only if needed. Use that in the init sequence. Signed-off-by: Simon Glass --- common/bloblist.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'common/bloblist.c') diff --git a/common/bloblist.c b/common/bloblist.c index 2144b10e1d0..6f2a4577708 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -476,6 +476,17 @@ int bloblist_init(void) log_debug("Found existing bloblist size %lx at %lx\n", size, addr); } + if (ret) + return log_msg_ret("ini", ret); + gd->flags |= GD_FLG_BLOBLIST_READY; + + return 0; +} - return ret; +int bloblist_maybe_init(void) +{ + if (CONFIG_IS_ENABLED(BLOBLIST) && !(gd->flags & GD_FLG_BLOBLIST_READY)) + return bloblist_init(); + + return 0; } -- cgit v1.2.3