All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Raymond Mao <raymond.mao@linaro.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Simon Glass <sjg@chromium.org>, Levi Yun <yeoreum.yun@arm.com>,
	Patrick Rudolph <patrick.rudolph@9elements.com>,
	Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 01/33] bloblist: add api to get blob with size
Date: Mon,  6 Jan 2025 07:31:57 -0700	[thread overview]
Message-ID: <20250106143229.3023771-2-sjg@chromium.org> (raw)
In-Reply-To: <20250106143229.3023771-1-sjg@chromium.org>

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
  *
-- 
2.34.1


  reply	other threads:[~2025-01-06 14:32 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06 14:31 [PATCH v2 00/33] upl: Prerequite patches for updated spec Simon Glass
2025-01-06 14:31 ` Simon Glass [this message]
2025-01-06 14:31 ` [PATCH v2 02/33] bloblist: Drop BSD license Simon Glass
2025-01-07 10:36   ` Ilias Apalodimas
2025-01-07 12:04     ` Simon Glass
2025-01-06 14:31 ` [PATCH v2 03/33] bloblist: Make BLOBLIST_ALLOC the default Simon Glass
2025-01-06 21:41   ` Tom Rini
2025-01-09 15:01     ` Simon Glass
2025-01-09 16:42       ` Tom Rini
2025-01-10 13:38         ` Simon Glass
2025-01-06 14:32 ` [PATCH v2 04/33] abuf: Provide a way to get the buffer address Simon Glass
2025-01-06 14:32 ` [PATCH v2 05/33] abuf: Allow use in host tools Simon Glass
2025-01-06 14:32 ` [PATCH v2 06/33] abuf: Provide a constant buffer Simon Glass
2025-01-06 14:32 ` [PATCH v2 07/33] cpu: Provide a way to get the physical-address size Simon Glass
2025-01-06 14:32 ` [PATCH v2 08/33] serial: Support info() method in ns16550 xPL with UPL Simon Glass
2025-01-06 14:32 ` [PATCH v2 09/33] mkimage: Update map_to_sysmem() to match its prototype Simon Glass
2025-01-06 14:32 ` [PATCH v2 10/33] x86: Enable meminfo command Simon Glass
2025-01-06 14:32 ` [PATCH v2 11/33] x86: Show the timestamp counter with bdinfo Simon Glass
2025-01-06 14:32 ` [PATCH v2 12/33] ofnode: Use 4K for a default tree-size Simon Glass
2025-01-08 18:33   ` Tom Rini
2025-01-09 12:37     ` Simon Glass
2025-01-06 14:32 ` [PATCH v2 13/33] ofnode: Indicate when out of space in a few places Simon Glass
2025-01-08 18:25   ` Tom Rini
2025-01-06 14:32 ` [PATCH v2 14/33] ofnode: Update of_add_subnode() to indicate name is alloced Simon Glass
2025-01-06 14:32 ` [PATCH v2 15/33] boot: Rename fit_image_get_data() Simon Glass
2025-01-06 14:32 ` [PATCH v2 16/33] boot: Rename fit_image_get_data_and_size() Simon Glass
2025-01-06 14:32 ` [PATCH v2 17/33] boot: Update fit_image_get_emb_data to use abuf Simon Glass
2025-01-08 18:25   ` Tom Rini
2025-01-09 12:36     ` Simon Glass
2025-01-09 15:09       ` Tom Rini
2025-01-09 15:14         ` Simon Glass
2025-01-09 18:08           ` Tom Rini
2025-01-10 13:39             ` Simon Glass
2025-01-10 16:17               ` Tom Rini
2025-01-10 19:23                 ` Simon Glass
2025-01-10 21:15                   ` Tom Rini
2025-01-06 14:32 ` [PATCH v2 18/33] boot: Use fit_image_get_data() to get data Simon Glass
2025-01-06 14:32 ` [PATCH v2 19/33] boot: Update fit_image_get_data() to use abuf Simon Glass
2025-01-06 14:32 ` [PATCH v2 20/33] test: Fix inpected typo in upl test Simon Glass
2025-01-06 14:32 ` [PATCH v2 21/33] emulation: fdt: Relax condition for OF_HAS_PRIOR_STAGE Simon Glass
2025-01-06 21:40   ` Tom Rini
2025-01-09 15:01     ` Simon Glass
2025-01-09 15:14       ` Tom Rini
2025-01-10 13:38         ` Simon Glass
2025-01-06 14:32 ` [PATCH v2 22/33] emulation: Use bloblist to hold tables Simon Glass
2025-01-09 22:28   ` Tom Rini
2025-01-06 14:32 ` [PATCH v2 23/33] x86: Create more space for SPL with qemu-x86_64 Simon Glass
2025-01-06 14:32 ` [PATCH v2 24/33] pci: video: Set up the pixel-format field Simon Glass
2025-01-06 14:32 ` [PATCH v2 25/33] x86: Show an error if video fails Simon Glass
2025-01-06 14:32 ` [PATCH v2 26/33] x86: Support jumping to a UPL image Simon Glass
2025-01-06 14:32 ` [PATCH v2 27/33] x86: Enable UPL handoff for SPL Simon Glass
2025-01-06 14:32 ` [PATCH v2 28/33] x86: Move tables to use SZ macros Simon Glass
2025-01-06 14:32 ` [PATCH v2 29/33] x86: Align the SMBIOS table to a 4K boundary Simon Glass
2025-01-06 14:32 ` [PATCH v2 30/33] x86: emulation: Enable bloblist Simon Glass
2025-01-06 14:32 ` [PATCH v2 31/33] dm: core: Clarify behaviour of ofnode_name_eq() Simon Glass
2025-01-06 14:32 ` [PATCH v2 32/33] dm: core: Provide ofnode_name_eq_unit() to accept a unit address Simon Glass
2025-01-06 14:32 ` [PATCH v2 33/33] dm: core: Provide ofnode_find_subnode_unit() Simon Glass
2025-01-06 21:42 ` [PATCH v2 00/33] upl: Prerequite patches for updated spec Tom Rini
2025-01-08 18:37 ` Tom Rini
2025-01-09 12:37   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250106143229.3023771-2-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=patrick.rudolph@9elements.com \
    --cc=raymond.mao@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=yeoreum.yun@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.