[U-Boot] [PATCH 1/2] fs: cbfs: make file_cbfs_load_header(..) independent of end-of-rom

Christian Gmeiner christian.gmeiner at gmail.com
Wed Apr 17 13:21:15 UTC 2019


Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
 fs/cbfs/cbfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
index 7b2513cb24..c60a8d5dc1 100644
--- a/fs/cbfs/cbfs.c
+++ b/fs/cbfs/cbfs.c
@@ -162,13 +162,10 @@ static void file_cbfs_fill_cache(u8 *start, u32 size, u32 align)
 }
 
 /* Get the CBFS header out of the ROM and do endian conversion. */
-static int file_cbfs_load_header(uintptr_t end_of_rom,
-				 struct cbfs_header *header)
+static int file_cbfs_load_header(uintptr_t addr, struct cbfs_header *header)
 {
-	struct cbfs_header *header_in_rom;
-	int32_t offset = *(u32 *)(end_of_rom - 3);
+	struct cbfs_header *header_in_rom = (struct cbfs_header *)addr;
 
-	header_in_rom = (struct cbfs_header *)(end_of_rom + offset + 1);
 	swap_header(header, header_in_rom);
 
 	if (header->magic != good_magic || header->offset >
@@ -183,8 +180,9 @@ void file_cbfs_init(uintptr_t end_of_rom)
 {
 	u8 *start_of_rom;
 	initialized = 0;
+	const int32_t offset = *(u32 *)(end_of_rom - 3);
 
-	if (file_cbfs_load_header(end_of_rom, &cbfs_header))
+	if (file_cbfs_load_header(end_of_rom + offset + 1, &cbfs_header))
 		return;
 
 	start_of_rom = (u8 *)(end_of_rom + 1 - cbfs_header.rom_size);
-- 
2.20.1



More information about the U-Boot mailing list