summaryrefslogtreecommitdiff
path: root/include/bloblist.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-12-27 13:07:00 -0800
committerSimon Glass <sjg@chromium.org>2023-12-31 07:21:02 -0700
commit1a2e02f955f98395142415d7c6cc14e4df903969 (patch)
tree59f3057b5cede46f4dcccf2fa9ecdcea6facf032 /include/bloblist.h
parente748e4b780057872b4a7192db87476adaa8b501c (diff)
bloblist: Adjust API to align in powers of 2
The updated bloblist structure stores the alignment as a power-of-two value in its structures. Adjust the API to use this, to avoid needing to calling ilog2(). Update the bloblist alignment from 16 bytes to 8 bytes. Drop a stale comment while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Co-developed-by: Raymond Mao <raymond.mao@linaro.org> Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'include/bloblist.h')
-rw-r--r--include/bloblist.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/bloblist.h b/include/bloblist.h
index 92dbfda21b4..5ad1337d1fb 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -76,7 +76,9 @@
enum {
BLOBLIST_VERSION = 0,
BLOBLIST_MAGIC = 0xb00757a3,
- BLOBLIST_ALIGN = 16,
+
+ BLOBLIST_ALIGN_LOG2 = 3,
+ BLOBLIST_ALIGN = 1 << BLOBLIST_ALIGN_LOG2,
};
/* Supported tags - add new ones to tag_name in bloblist.c */
@@ -254,11 +256,11 @@ void *bloblist_find(uint tag, int size);
*
* @tag: Tag to add (enum bloblist_tag_t)
* @size: Size of the blob
- * @align: Alignment of the blob (in bytes), 0 for default
+ * @align_log2: Alignment of the blob (in bytes log2), 0 for default
* Return: pointer to the newly added block, or NULL if there is not enough
* space for the blob
*/
-void *bloblist_add(uint tag, int size, int align);
+void *bloblist_add(uint tag, int size, int align_log2);
/**
* bloblist_ensure_size() - Find or add a blob
@@ -268,11 +270,11 @@ void *bloblist_add(uint tag, int size, int align);
* @tag: Tag to add (enum bloblist_tag_t)
* @size: Size of the blob
* @blobp: Returns a pointer to blob on success
- * @align: Alignment of the blob (in bytes), 0 for default
+ * @align_log2: Alignment of the blob (in bytes log2), 0 for default
* Return: 0 if OK, -ENOSPC if it is missing and could not be added due to lack
* of space, or -ESPIPE it exists but has the wrong size
*/
-int bloblist_ensure_size(uint tag, int size, int align, void **blobp);
+int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp);
/**
* bloblist_ensure() - Find or add a blob