spl: spi: Do not hardcode fixed size for header
authorMichal Simek <michal.simek@xilinx.com>
Thu, 4 Oct 2018 07:30:20 +0000 (09:30 +0200)
committerTom Rini <trini@konsulko.com>
Sat, 6 Oct 2018 18:09:42 +0000 (14:09 -0400)
Find out size directly from header structure.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
common/spl/spl_spi.c

index ddc33fd3ce6fb19edb32dfa5a4f145e093961ecf..8cd4830a39b89d747fb1e4cb6179cc4d2da2559f 100644 (file)
@@ -28,7 +28,7 @@ static int spi_load_image_os(struct spl_image_info *spl_image,
        int err;
 
        /* Read for a header, parse or error out. */
-       spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, 0x40,
+       spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header),
                       (void *)header);
 
        if (image_get_magic(header) != IH_MAGIC)
@@ -88,7 +88,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
                return -ENODEV;
        }
 
-       header = spl_get_load_buffer(-sizeof(*header), 0x40);
+       header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
 
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
        payload_offs = fdtdec_get_config_int(gd->fdt_blob,
@@ -101,7 +101,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 #endif
        {
                /* Load u-boot, mkimage header is 64 bytes. */
-               err = spi_flash_read(flash, payload_offs, 0x40,
+               err = spi_flash_read(flash, payload_offs, sizeof(*header),
                                     (void *)header);
                if (err) {
                        debug("%s: Failed to read from SPI flash (err=%d)\n",