diff mbox series

[06/13] cbfs: Adjust cbfs_load_header_ptr() to use cbfs_priv

Message ID 20200513142359.147589-7-sjg@chromium.org
State Superseded
Headers show
Series x86: cbfs: Various clean-ups to CBFS implementation | expand

Commit Message

Simon Glass May 13, 2020, 2:23 p.m. UTC
This function is strange at the moment in that it takes a header pointer
but then accesses the cbfs_s global. Currently clients have their own priv
pointer, so update the function to take that as a parameter instead.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 fs/cbfs/cbfs.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Bin Meng May 19, 2020, 2:04 p.m. UTC | #1
On Wed, May 13, 2020 at 10:24 PM Simon Glass <sjg at chromium.org> wrote:
>
> This function is strange at the moment in that it takes a header pointer
> but then accesses the cbfs_s global. Currently clients have their own priv
> pointer, so update the function to take that as a parameter instead.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  fs/cbfs/cbfs.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
index 765e078423..05de58cf19 100644
--- a/fs/cbfs/cbfs.c
+++ b/fs/cbfs/cbfs.c
@@ -8,6 +8,9 @@ 
 #include <malloc.h>
 #include <asm/byteorder.h>
 
+/* Offset of master header from the start of a coreboot ROM */
+#define MASTER_HDR_OFFSET	0x38
+
 static const u32 good_magic = 0x4f524243;
 static const u8 good_file_magic[] = "LARCHIVE";
 
@@ -192,9 +195,9 @@  static int file_cbfs_load_header(struct cbfs_priv *priv, ulong end_of_rom)
 	return 0;
 }
 
-static int cbfs_load_header_ptr(struct cbfs_priv *priv, ulong base,
-				struct cbfs_header *header)
+static int cbfs_load_header_ptr(struct cbfs_priv *priv, ulong base)
 {
+	struct cbfs_header *header = &priv->header;
 	struct cbfs_header *header_in_rom;
 
 	header_in_rom = (struct cbfs_header *)base;
@@ -241,7 +244,7 @@  int cbfs_init_mem(ulong base, ulong size, struct cbfs_priv **privp)
 	 * valid. Assume that a master header appears at the start, at offset
 	 * 0x38.
 	 */
-	ret = cbfs_load_header_ptr(priv, base + 0x38, &priv->header);
+	ret = cbfs_load_header_ptr(priv, base + MASTER_HDR_OFFSET);
 	if (ret)
 		return ret;