bloblist: add api to get blob with size
bloblist_find function only returns the pointer of blob data,
which is fine for those self-describing data like FDT.
But as a common scenario, an interface is needed to retrieve both
the pointer and the size of the blob data.
Add a few ut test cases for the new api.
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/common/bloblist.c b/common/bloblist.c
index 110bb9d..ab48a3c 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -223,13 +223,26 @@
void *bloblist_find(uint tag, int size)
{
+ void *blob = NULL;
+ int blob_size;
+
+ blob = bloblist_get_blob(tag, &blob_size);
+
+ if (size && size != blob_size)
+ return NULL;
+
+ return blob;
+}
+
+void *bloblist_get_blob(uint tag, int *sizep)
+{
struct bloblist_rec *rec;
rec = bloblist_findrec(tag);
if (!rec)
return NULL;
- if (size && size != rec->size)
- return NULL;
+
+ *sizep = rec->size;
return (void *)rec + rec_hdr_size(rec);
}