diff options
author | Raymond Mao | 2024-02-03 08:36:22 -0800 |
---|---|---|
committer | Tom Rini | 2024-02-29 09:24:22 -0500 |
commit | 1ef43f3bf20a4a9508c299a738d01faa3dc3ce95 (patch) | |
tree | f433886d55930ffe50ed879f8bb3f60dc4ef9884 /common | |
parent | 67254214930cd2cb52279b01690c1f820a7f83db (diff) |
bloblist: refactor of bloblist_reloc()
The current bloblist pointer and size can be retrieved from global
data, so we don't need to pass them from the function arguments.
This change also help to remove all external access of gd->bloblist
outside of bloblist module.
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/bloblist.c | 10 | ||||
-rw-r--r-- | common/board_f.c | 9 |
2 files changed, 11 insertions, 8 deletions
diff --git a/common/bloblist.c b/common/bloblist.c index 26b0ba33b11..c2fd07575fb 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -472,13 +472,19 @@ void bloblist_show_list(void) } } -void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) +int bloblist_reloc(void *to, uint to_size) { struct bloblist_hdr *hdr; - memcpy(to, from, from_size); + if (to_size < gd->bloblist->total_size) + return -ENOSPC; + + memcpy(to, gd->bloblist, gd->bloblist->total_size); hdr = to; hdr->total_size = to_size; + gd->bloblist = to; + + return 0; } int bloblist_init(void) diff --git a/common/board_f.c b/common/board_f.c index 442b8349d08..7e313691028 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -706,13 +706,10 @@ static int reloc_bloblist(void) return 0; } if (gd->new_bloblist) { - int size = CONFIG_BLOBLIST_SIZE; - debug("Copying bloblist from %p to %p, size %x\n", - gd->bloblist, gd->new_bloblist, size); - bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC, - gd->bloblist, size); - gd->bloblist = gd->new_bloblist; + gd->bloblist, gd->new_bloblist, gd->bloblist->total_size); + return bloblist_reloc(gd->new_bloblist, + CONFIG_BLOBLIST_SIZE_RELOC); } #endif |