From patchwork Fri May 22 16:32:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246314 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Fri, 22 May 2020 10:32:14 -0600 Subject: [PATCH v3 13/13] cbfs: Don't require the CBFS size with cbfs_init_mem() In-Reply-To: <20200522163214.120309-1-sjg@chromium.org> References: <20200522163214.120309-1-sjg@chromium.org> Message-ID: <20200522103142.v3.13.I00c7b946bb6c940b57864993d9c704fe25cf03d2@changeid> The size is not actually used since it is present in the header. Drop this parameter. Also tidy up error handling while we are here. Reviewed-by: Bin Meng Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Rebase to master (with x86/master cherry-picked in too) - Resending as some comments / reviews were missed arch/x86/lib/fsp2/fsp_init.c | 3 +-- fs/cbfs/cbfs.c | 10 ++++++---- include/cbfs.h | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/lib/fsp2/fsp_init.c b/arch/x86/lib/fsp2/fsp_init.c index 8c577902b27..85cae54a0ca 100644 --- a/arch/x86/lib/fsp2/fsp_init.c +++ b/arch/x86/lib/fsp2/fsp_init.c @@ -81,11 +81,10 @@ static int get_cbfs_fsp(enum fsp_type_t type, ulong map_base, * 'COREBOOT' (CBFS, size 1814528, offset 2117632). */ ulong cbfs_base = 0x205000; - ulong cbfs_size = 0x1bb000; struct cbfs_priv *cbfs; int ret; - ret = cbfs_init_mem(map_base + cbfs_base, cbfs_size, &cbfs); + ret = cbfs_init_mem(map_base + cbfs_base, &cbfs); if (ret) return ret; if (!ret) { diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c index 9772962ceec..b17cc6dc841 100644 --- a/fs/cbfs/cbfs.c +++ b/fs/cbfs/cbfs.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -275,7 +276,7 @@ int file_cbfs_init(ulong end_of_rom) return cbfs_init(&cbfs_s, end_of_rom); } -int cbfs_init_mem(ulong base, ulong size, struct cbfs_priv **privp) +int cbfs_init_mem(ulong base, struct cbfs_priv **privp) { struct cbfs_priv priv_s, *priv = &priv_s; int ret; @@ -288,9 +289,10 @@ int cbfs_init_mem(ulong base, ulong size, struct cbfs_priv **privp) if (ret) return ret; - file_cbfs_fill_cache(priv, priv->header.rom_size, priv->header.align); - if (priv->result != CBFS_SUCCESS) - return -EINVAL; + ret = file_cbfs_fill_cache(priv, priv->header.rom_size, + priv->header.align); + if (ret) + return log_msg_ret("fill", ret); priv->initialised = true; priv = malloc(sizeof(priv_s)); diff --git a/include/cbfs.h b/include/cbfs.h index 2a4eca05050..56d5c1680c6 100644 --- a/include/cbfs.h +++ b/include/cbfs.h @@ -149,11 +149,10 @@ const struct cbfs_cachenode *cbfs_find_file(struct cbfs_priv *cbfs, * cbfs_init_mem() - Set up a new CBFS * * @base: Base address of CBFS - * @size: Size of CBFS in bytes * @cbfsp: Returns a pointer to CBFS on success * @return 0 if OK, -ve on error */ -int cbfs_init_mem(ulong base, ulong size, struct cbfs_priv **privp); +int cbfs_init_mem(ulong base, struct cbfs_priv **privp); /***************************************************************************/