Signed-off-by: Christian Gmeiner <christian.gmei...@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to