summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-01-27 08:49:50 -0700
committerSimon Glass <sjg@chromium.org>2020-02-05 19:33:46 -0700
commit5b044548f5ae3e5f7cfbd4a6399f0695b4fb709b (patch)
tree35559c0f03ee22ce6a18199c695fdc9edf18618b /common
parent9ff5e0495d4bc8aee79c712a8603ef9bd7c06cd7 (diff)
bloblist: Add a new function to add or check size
A common check is to see if a blob is present, create it if not and make sure that the size is large enough. Add a function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/bloblist.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/common/bloblist.c b/common/bloblist.c
index ccf5e4b6f6..3599ffa75c 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -85,8 +85,10 @@ static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size)
rec = bloblist_findrec(tag);
if (rec) {
- if (size && size != rec->size)
+ if (size && size != rec->size) {
+ *recp = rec;
return -ESPIPE;
+ }
} else {
int ret;
@@ -145,6 +147,21 @@ void *bloblist_ensure(uint tag, int size)
return (void *)rec + rec->hdr_size;
}
+int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp)
+{
+ struct bloblist_rec *rec;
+ int ret;
+
+ ret = bloblist_ensurerec(tag, &rec, *sizep);
+ if (ret == -ESPIPE)
+ *sizep = rec->size;
+ else if (ret)
+ return ret;
+ *blobp = (void *)rec + rec->hdr_size;
+
+ return 0;
+}
+
static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr)
{
struct bloblist_rec *rec;