[U-Boot] [PATCH v2 19/27] spl: Convert spl_spi_load_image() to use linker list

Simon Glass sjg at chromium.org
Sun Sep 25 02:20:09 CEST 2016


Add a linker list declaration for this method and remove the explicit
switch() code. Also set up the sunxi function.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 common/spl/spl.c                | 4 ----
 common/spl/spl_spi.c            | 4 +++-
 drivers/mtd/spi/sunxi_spi_spl.c | 4 +++-
 include/spl.h                   | 3 ---
 4 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 3f4e48a..9c8dcbb 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -373,10 +373,6 @@ static int spl_load_image(u32 boot_device)
 		return loader->load_image(&bootdev);
 
 	switch (boot_device) {
-#if defined(CONFIG_SPL_SPI_SUPPORT) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
-	case BOOT_DEVICE_SPI:
-		return spl_spi_load_image(&bootdev);
-#endif
 #ifdef CONFIG_SPL_ETH_SUPPORT
 	case BOOT_DEVICE_CPGMAC:
 #ifdef CONFIG_SPL_ETH_DEVICE
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index e4cc0d0..b9294f2 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -65,7 +65,7 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
  * configured and available since this code loads the main U-Boot image
  * from SPI into SDRAM and starts it from there.
  */
-int spl_spi_load_image(struct spl_boot_device *bootdev)
+static int spl_spi_load_image(struct spl_boot_device *bootdev)
 {
 	int err = 0;
 	struct spi_flash *flash;
@@ -121,3 +121,5 @@ int spl_spi_load_image(struct spl_boot_device *bootdev)
 
 	return err;
 }
+/* Use priorty 1 so that boards can override this */
+SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_SPI, spl_spi_load_image);
diff --git a/drivers/mtd/spi/sunxi_spi_spl.c b/drivers/mtd/spi/sunxi_spi_spl.c
index 767959c..70d6d15 100644
--- a/drivers/mtd/spi/sunxi_spi_spl.c
+++ b/drivers/mtd/spi/sunxi_spi_spl.c
@@ -262,7 +262,7 @@ static void spi0_read_data(void *buf, u32 addr, u32 len)
 
 /*****************************************************************************/
 
-int spl_spi_load_image(struct spl_boot_device *bootdev)
+static int spl_spi_load_image(struct spl_boot_device *bootdev)
 {
 	int err;
 	struct image_header *header;
@@ -281,3 +281,5 @@ int spl_spi_load_image(struct spl_boot_device *bootdev)
 	spi0_deinit();
 	return 0;
 }
+/* Use priorty 0 to override the default if it happens to be linked in */
+SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_SPI, spl_spi_load_image);
diff --git a/include/spl.h b/include/spl.h
index 279896d..29dcf5b 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -181,9 +181,6 @@ struct spl_image_loader {
 		.load_image = __method, \
 	}
 
-/* SPI SPL functions */
-int spl_spi_load_image(struct spl_boot_device *bootdev);
-
 /* Ethernet SPL functions */
 int spl_net_load_image(struct spl_boot_device *bootdev);
 
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list