
From: Raymond Mao raymond.mao@linaro.org
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.
Signed-off-by: Raymond Mao raymond.mao@linaro.org Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org Signed-off-by: Simon Glass sjg@chromium.org ---
(no changes since v1)
common/bloblist.c | 17 +++++++++++++++-- include/bloblist.h | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/common/bloblist.c b/common/bloblist.c index e8acfc74331..ecce3da9331 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -223,14 +223,27 @@ static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size, }
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 *size) { struct bloblist_rec *rec;
rec = bloblist_findrec(tag); if (!rec) return NULL; - if (size && size != rec->size) - return NULL; + + *size = rec->size;
return (void *)rec + rec_hdr_size(rec); } diff --git a/include/bloblist.h b/include/bloblist.h index 1e1ca34aa92..7d462e71914 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -251,6 +251,24 @@ static inline void *bloblist_check_magic(ulong addr) return ptr; }
+#if CONFIG_IS_ENABLED(BLOBLIST) +/** + * bloblist_get_blob() - Find a blob and get the size of it + * + * Searches the bloblist and returns the blob with the matching tag + * + * @tag: Tag to search for (enum bloblist_tag_t) + * @size: Size of the blob found + * Return: pointer to bloblist if found, or NULL if not found + */ +void *bloblist_get_blob(uint tag, int *size); +#else +static inline void *bloblist_get_blob(uint tag, int *size) +{ + return NULL; +} +#endif + /** * bloblist_find() - Find a blob *