spl: Update ext functions to take an spl_image parameter
authorSimon Glass <sjg@chromium.org>
Sun, 25 Sep 2016 00:20:14 +0000 (18:20 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 6 Oct 2016 19:08:53 +0000 (15:08 -0400)
Update the ext loader to avoid using the spl_image global variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/spl/spl_ext.c
common/spl/spl_mmc.c
drivers/mtd/spi/sunxi_spi_spl.c
include/spl.h

index e5af24ec8b8cc0b9f975d71ca3e750ac44f292ad..b93e1eacd3033bc10f3c528791a43153b1151e79 100644 (file)
@@ -10,9 +10,9 @@
 #include <image.h>
 
 #ifdef CONFIG_SPL_EXT_SUPPORT
-int spl_load_image_ext(struct blk_desc *block_dev,
-                                               int partition,
-                                               const char *filename)
+int spl_load_image_ext(struct spl_image_info *spl_image,
+                      struct blk_desc *block_dev, int partition,
+                      const char *filename)
 {
        s32 err;
        struct image_header *header;
@@ -48,13 +48,13 @@ int spl_load_image_ext(struct blk_desc *block_dev,
                goto end;
        }
 
-       err = spl_parse_image_header(&spl_image, header);
+       err = spl_parse_image_header(spl_image, header);
        if (err < 0) {
                puts("spl: ext: failed to parse image header\n");
                goto end;
        }
 
-       err = ext4fs_read((char *)spl_image.load_addr, filelen, &actlen);
+       err = ext4fs_read((char *)spl_image->load_addr, filelen, &actlen);
 
 end:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
@@ -67,7 +67,8 @@ end:
 }
 
 #ifdef CONFIG_SPL_OS_BOOT
-int spl_load_image_ext_os(struct blk_desc *block_dev, int partition)
+int spl_load_image_ext_os(struct spl_image_info *spl_image,
+                         struct blk_desc *block_dev, int partition)
 {
        int err;
        __maybe_unused loff_t filelen, actlen;
@@ -104,7 +105,8 @@ int spl_load_image_ext_os(struct blk_desc *block_dev, int partition)
                }
                file = getenv("falcon_image_file");
                if (file) {
-                       err = spl_load_image_ext(block_dev, partition, file);
+                       err = spl_load_image_ext(spl_image, block_dev,
+                                                partition, file);
                        if (err != 0) {
                                puts("spl: falling back to default\n");
                                goto defaults;
@@ -134,11 +136,12 @@ defaults:
                return -1;
        }
 
-       return spl_load_image_ext(block_dev, partition,
+       return spl_load_image_ext(spl_image, block_dev, partition,
                        CONFIG_SPL_FS_LOAD_KERNEL_NAME);
 }
 #else
-int spl_load_image_ext_os(struct blk_desc *block_dev, int partition)
+int spl_load_image_ext_os(struct spl_image_info *spl_image,
+                         struct blk_desc *block_dev, int partition)
 {
        return -ENOSYS;
 }
index 6536e66ab0c268be3f5a2cc8d8b329d42061ed89..5f5d9d0c3e0626676b9f54e415a6b50d3f0f824b 100644 (file)
@@ -245,13 +245,13 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
 #endif
 #ifdef CONFIG_SPL_EXT_SUPPORT
        if (!spl_start_uboot()) {
-               err = spl_load_image_ext_os(&mmc->block_dev,
+               err = spl_load_image_ext_os(spl_image, &mmc->block_dev,
                        CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
                if (!err)
                        return err;
        }
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-       err = spl_load_image_ext(&mmc->block_dev,
+       err = spl_load_image_ext(spl_image, &mmc->block_dev,
                                 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
                                 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
        if (!err)
index 70d6d1514da30b196a9493a1e78575c24a861db3..67c7edd92d0c6b1d7b20d072ab50085ce9bcc5b8 100644 (file)
@@ -262,7 +262,8 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)
 
 /*****************************************************************************/
 
-static int spl_spi_load_image(struct spl_boot_device *bootdev)
+static int spl_spi_load_image(struct spl_image_info *spl_image,
+                             struct spl_boot_device *bootdev)
 {
        int err;
        struct image_header *header;
@@ -271,12 +272,12 @@ static int spl_spi_load_image(struct spl_boot_device *bootdev)
        spi0_init();
 
        spi0_read_data((void *)header, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40);
-       err = spl_parse_image_header(&spl_image, header);
+       err = spl_parse_image_header(spl_image, header);
        if (err)
                return err;
 
-       spi0_read_data((void *)spl_image.load_addr, CONFIG_SYS_SPI_U_BOOT_OFFS,
-                      spl_image.size);
+       spi0_read_data((void *)spl_image->load_addr, CONFIG_SYS_SPI_U_BOOT_OFFS,
+                      spl_image->size);
 
        spi0_deinit();
        return 0;
index dd1d6099ce23959c230d43938c9e92e314ac8461..5ef9ae6e4bbd3385e3c4978622781f9f9b60dd60 100644 (file)
@@ -191,9 +191,11 @@ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition);
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
 
 /* SPL EXT image functions */
-int spl_load_image_ext(struct blk_desc *block_dev, int partition,
+int spl_load_image_ext(struct spl_image_info *spl_image,
+                      struct blk_desc *block_dev, int partition,
                       const char *filename);
-int spl_load_image_ext_os(struct blk_desc *block_dev, int partition);
+int spl_load_image_ext_os(struct spl_image_info *spl_image,
+                         struct blk_desc *block_dev, int partition);
 
 /**
  * spl_init() - Set up device tree and driver model in SPL if enabled