public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list
@ 2016-11-17 17:29 Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 1/8] spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro Simon Glass
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

At present we have a linker list for all the image-loader methods but
announce_boot_device() uses its own switch() statement with the names of
each method. We may as well combine the name into the linker list.

The names are only needed if libcommon support is enabled, since printf()
is used to display then.

This series performs this adjustment, by adding the names and then
converting the generic SPL code over to use them. This allows the
board-specific spl_board_announce_boot_device() functions to be dropped as
well.


Simon Glass (8):
  spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro
  spl: Add a name to the SPL load-image methods
  spl: Move the loading code into its own function
  spl: Pass the loader into spl_load_image()
  spl: Drop announce_boot_device()
  spl: sunxi: Drop spl_board_announce_boot_device()
  spl: uniphier: Drop spl_board_announce_boot_device()
  spl: sandbox: Drop spl_board_announce_boot_device()

 arch/arm/mach-sunxi/board.c                  |  11 +--
 arch/arm/mach-uniphier/boot-mode/spl_board.c |   7 +-
 arch/sandbox/cpu/spl.c                       |  19 +---
 common/spl/spl.c                             | 125 ++++++---------------------
 common/spl/spl_mmc.c                         |   6 +-
 common/spl/spl_nand.c                        |   2 +-
 common/spl/spl_net.c                         |   5 +-
 common/spl/spl_nor.c                         |   2 +-
 common/spl/spl_onenand.c                     |   3 +-
 common/spl/spl_sata.c                        |   2 +-
 common/spl/spl_spi.c                         |   2 +-
 common/spl/spl_ubi.c                         |   4 +-
 common/spl/spl_usb.c                         |   2 +-
 common/spl/spl_ymodem.c                      |   2 +-
 drivers/mtd/spi/sunxi_spi_spl.c              |   2 +-
 include/spl.h                                |  27 ++++--
 16 files changed, 70 insertions(+), 151 deletions(-)

-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/8] spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 2/8] spl: Add a name to the SPL load-image methods Simon Glass
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

A double underscore is normally reserved for compiler predefines. Use a
single underscore instead.

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

 include/spl.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/spl.h b/include/spl.h
index e080a82..11bdc2d 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -172,15 +172,15 @@ struct spl_image_loader {
 	ll_entry_declare(struct spl_image_loader, __name, spl_image_loader)
 
 /*
- * __priority is the priority of this method, 0 meaning it will be the top
+ * _priority is the priority of this method, 0 meaning it will be the top
  * choice for this device, 9 meaning it is the bottom choice.
- * __boot_device is the BOOT_DEVICE_... value
- * __method is the load_image function to call
+ * _boot_device is the BOOT_DEVICE_... value
+ * _method is the load_image function to call
  */
-#define SPL_LOAD_IMAGE_METHOD(__priority, __boot_device, __method) \
-	SPL_LOAD_IMAGE(__method ## __priority ## __boot_device) = { \
-		.boot_device = __boot_device, \
-		.load_image = __method, \
+#define SPL_LOAD_IMAGE_METHOD(_priority, _boot_device, _method) \
+	SPL_LOAD_IMAGE(_method ## _priority ## _boot_device) = { \
+		.boot_device = _boot_device, \
+		.load_image = _method, \
 	}
 
 /* SPL FAT image functions */
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/8] spl: Add a name to the SPL load-image methods
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 1/8] spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function Simon Glass
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

It is useful to name each method so that we can print out this name when
using the method. Currently this happens using a separate function. In
preparation for unifying this, add a name to each method.

The name is only available if we have libcommon support (i.e can use
printf()).

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

 arch/arm/mach-sunxi/board.c                  |  2 +-
 arch/arm/mach-uniphier/boot-mode/spl_board.c |  2 +-
 arch/sandbox/cpu/spl.c                       |  2 +-
 common/spl/spl.c                             |  4 ++--
 common/spl/spl_mmc.c                         |  6 +++---
 common/spl/spl_nand.c                        |  2 +-
 common/spl/spl_net.c                         |  5 +++--
 common/spl/spl_nor.c                         |  2 +-
 common/spl/spl_onenand.c                     |  3 ++-
 common/spl/spl_sata.c                        |  2 +-
 common/spl/spl_spi.c                         |  2 +-
 common/spl/spl_ubi.c                         |  4 ++--
 common/spl/spl_usb.c                         |  2 +-
 common/spl/spl_ymodem.c                      |  2 +-
 drivers/mtd/spi/sunxi_spi_spl.c              |  2 +-
 include/spl.h                                | 15 ++++++++++++++-
 16 files changed, 36 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 0f8ead9..205236d 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -142,7 +142,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image);
+SPL_LOAD_IMAGE_METHOD("FEL", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
 #endif
 
 void s_init(void)
diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c
index 854ab05..ba84087 100644
--- a/arch/arm/mach-uniphier/boot-mode/spl_board.c
+++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c
@@ -127,4 +127,4 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image);
+SPL_LOAD_IMAGE_METHOD("eMMC", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 1ad7fb6..632446b 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -51,7 +51,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 	/* Hopefully this will not return */
 	return os_spl_to_uboot(fname);
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_BOARD, spl_board_load_image);
+SPL_LOAD_IMAGE_METHOD("sandbox", 0, BOOT_DEVICE_BOARD, spl_board_load_image);
 
 void spl_board_init(void)
 {
diff --git a/common/spl/spl.c b/common/spl/spl.c
index bdb165a..4f23c0e 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -220,9 +220,9 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_RAM, spl_ram_load_image);
+SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM, spl_ram_load_image);
 #if defined(CONFIG_SPL_DFU_SUPPORT)
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_DFU, spl_ram_load_image);
+SPL_LOAD_IMAGE_METHOD("USB DFU", 0, BOOT_DEVICE_DFU, spl_ram_load_image);
 #endif
 #endif
 
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index c674e61..97edf78 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -352,6 +352,6 @@ static int spl_mmc_load_image(struct spl_image_info *spl_image,
 	return err;
 }
 
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC1, spl_mmc_load_image);
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC2, spl_mmc_load_image);
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image);
+SPL_LOAD_IMAGE_METHOD("MMC1", 0, BOOT_DEVICE_MMC1, spl_mmc_load_image);
+SPL_LOAD_IMAGE_METHOD("MMC2", 0, BOOT_DEVICE_MMC2, spl_mmc_load_image);
+SPL_LOAD_IMAGE_METHOD("MMC2_2", 0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image);
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index d1abda6..cd39f9b 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -151,4 +151,4 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
 }
 #endif
 /* Use priorty 1 so that Ubi can override this */
-SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_NAND, spl_nand_load_image);
+SPL_LOAD_IMAGE_METHOD("NAND", 1, BOOT_DEVICE_NAND, spl_nand_load_image);
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index f4b4bc4..0fba017 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -51,7 +51,8 @@ int spl_net_load_image_cpgmac(struct spl_image_info *spl_image,
 
 	return spl_net_load_image(spl_image, bootdev);
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_CPGMAC, spl_net_load_image_cpgmac);
+SPL_LOAD_IMAGE_METHOD("eth device", 0, BOOT_DEVICE_CPGMAC,
+		      spl_net_load_image_cpgmac);
 #endif
 
 #ifdef CONFIG_SPL_USBETH_SUPPORT
@@ -62,5 +63,5 @@ int spl_net_load_image_usb(struct spl_image_info *spl_image,
 
 	return spl_net_load_image(spl_image, bootdev);
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
+SPL_LOAD_IMAGE_METHOD("USB eth", 0, BOOT_DEVICE_USBETH, spl_net_load_image_usb);
 #endif
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 6bfa399..d07ca84 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -71,4 +71,4 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_NOR, spl_nor_load_image);
+SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image);
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index f076e2c..fc98e9c 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -36,4 +36,5 @@ static int spl_onenand_load_image(struct spl_image_info *spl_image,
 	return 0;
 }
 /* Use priorty 1 so that Ubi can override this */
-SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_ONENAND, spl_onenand_load_image);
+SPL_LOAD_IMAGE_METHOD("OneNAND", 1, BOOT_DEVICE_ONENAND,
+		      spl_onenand_load_image);
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index a3c07cd..5476206 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -57,4 +57,4 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_SATA, spl_sata_load_image);
+SPL_LOAD_IMAGE_METHOD("SATA", 0, BOOT_DEVICE_SATA, spl_sata_load_image);
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index a3caafb..7388dda 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -124,4 +124,4 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 	return err;
 }
 /* Use priorty 1 so that boards can override this */
-SPL_LOAD_IMAGE_METHOD(1, BOOT_DEVICE_SPI, spl_spi_load_image);
+SPL_LOAD_IMAGE_METHOD("SPI", 1, BOOT_DEVICE_SPI, spl_spi_load_image);
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index c03910b..24633f4 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -78,5 +78,5 @@ out:
 	return ret;
 }
 /* Use priorty 0 so that Ubi will override NAND and ONENAND methods */
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_NAND, spl_ubi_load_image);
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_ONENAND, spl_ubi_load_image);
+SPL_LOAD_IMAGE_METHOD("NAND", 0, BOOT_DEVICE_NAND, spl_ubi_load_image);
+SPL_LOAD_IMAGE_METHOD("OneNAND", 0, BOOT_DEVICE_ONENAND, spl_ubi_load_image);
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index e37966e..567a450 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -65,4 +65,4 @@ static int spl_usb_load_image(struct spl_image_info *spl_image,
 
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_USB, spl_usb_load_image);
+SPL_LOAD_IMAGE_METHOD("USB", 0, BOOT_DEVICE_USB, spl_usb_load_image);
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 13e8e51..5d1db7d 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -133,4 +133,4 @@ end_stream:
 	printf("Loaded %d bytes\n", size);
 	return 0;
 }
-SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_UART, spl_ymodem_load_image);
+SPL_LOAD_IMAGE_METHOD("UART", 0, BOOT_DEVICE_UART, spl_ymodem_load_image);
diff --git a/drivers/mtd/spi/sunxi_spi_spl.c b/drivers/mtd/spi/sunxi_spi_spl.c
index 67c7edd..2159f38 100644
--- a/drivers/mtd/spi/sunxi_spi_spl.c
+++ b/drivers/mtd/spi/sunxi_spi_spl.c
@@ -283,4 +283,4 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 	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);
+SPL_LOAD_IMAGE_METHOD("sunxi SPI" 0, BOOT_DEVICE_SPI, spl_spi_load_image);
diff --git a/include/spl.h b/include/spl.h
index 11bdc2d..3470733 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -152,10 +152,14 @@ struct spl_boot_device {
 /**
  * Holds information about a way of loading an SPL image
  *
+ * @name: User-friendly name for this method (e.g. "MMC")
  * @boot_device: Boot device that this loader supports
  * @load_image: Function to call to load image
  */
 struct spl_image_loader {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+	const char *name;
+#endif
 	uint boot_device;
 	/**
 	 * load_image() - Load an SPL image
@@ -177,11 +181,20 @@ struct spl_image_loader {
  * _boot_device is the BOOT_DEVICE_... value
  * _method is the load_image function to call
  */
-#define SPL_LOAD_IMAGE_METHOD(_priority, _boot_device, _method) \
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \
 	SPL_LOAD_IMAGE(_method ## _priority ## _boot_device) = { \
+		.name = _name, \
 		.boot_device = _boot_device, \
 		.load_image = _method, \
 	}
+#else
+#define SPL_LOAD_IMAGE_METHOD(_name, _priority, _boot_device, _method) \
+	SPL_LOAD_IMAGE(_method ## _priority ## _boot_device) = { \
+		.boot_device = _boot_device, \
+		.load_image = _method, \
+	}
+#endif
 
 /* SPL FAT image functions */
 int spl_load_image_fat(struct spl_image_info *spl_image,
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 1/8] spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 2/8] spl: Add a name to the SPL load-image methods Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-22  7:31   ` Masahiro Yamada
  2016-11-28 20:09   ` [U-Boot] [U-Boot, " Tom Rini
  2016-11-17 17:29 ` [U-Boot] [PATCH 4/8] spl: Pass the loader into spl_load_image() Simon Glass
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

Create a boot_from_devices() function to handle trying each device. This
helps to reduce the size of the already-large board_init_r() function.

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

 common/spl/spl.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4f23c0e..8c3a47d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -372,12 +372,29 @@ static int spl_load_image(struct spl_image_info *spl_image, u32 boot_device)
 
 	bootdev.boot_device = boot_device;
 	bootdev.boot_device_name = NULL;
-	if (loader)
-		return loader->load_image(spl_image, &bootdev);
 
+	return loader->load_image(spl_image, &bootdev);
+}
+
+static int boot_from_devices(struct spl_image_info *spl_image,
+			     u32 spl_boot_list[])
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
+	     spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
+		struct spl_image_loader *loader;
+
+		announce_boot_device(spl_boot_list[i]);
+		loader = spl_ll_find_loader(spl_boot_list[i]);
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-	puts("SPL: Unsupported Boot Device!\n");
+		if (!loader)
+			puts("SPL: Unsupported Boot Device!\n");
 #endif
+		if (loader && !spl_load_image(spl_image, spl_boot_list[i]))
+			return 0;
+	}
+
 	return -ENODEV;
 }
 
@@ -391,7 +408,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		BOOT_DEVICE_NONE,
 	};
 	struct spl_image_info spl_image;
-	int i;
 
 	debug(">>spl:board_init_r()\n");
 
@@ -418,15 +434,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 
 	memset(&spl_image, '\0', sizeof(spl_image));
 	board_boot_order(spl_boot_list);
-	for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
-			spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
-		announce_boot_device(spl_boot_list[i]);
-		if (!spl_load_image(&spl_image, spl_boot_list[i]))
-			break;
-	}
 
-	if (i == ARRAY_SIZE(spl_boot_list) ||
-	    spl_boot_list[i] == BOOT_DEVICE_NONE) {
+	if (boot_from_devices(&spl_image, spl_boot_list)) {
 		puts("SPL: failed to boot from all boot devices\n");
 		hang();
 	}
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 4/8] spl: Pass the loader into spl_load_image()
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
                   ` (2 preceding siblings ...)
  2016-11-17 17:29 ` [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 5/8] spl: Drop announce_boot_device() Simon Glass
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

Rather than have this function figure out the correct loader again, pass
it in as a parameter.

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

 common/spl/spl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 8c3a47d..4555216 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -365,12 +365,12 @@ static struct spl_image_loader *spl_ll_find_loader(uint boot_device)
 	return NULL;
 }
 
-static int spl_load_image(struct spl_image_info *spl_image, u32 boot_device)
+static int spl_load_image(struct spl_image_info *spl_image,
+			  struct spl_image_loader *loader)
 {
 	struct spl_boot_device bootdev;
-	struct spl_image_loader *loader = spl_ll_find_loader(boot_device);
 
-	bootdev.boot_device = boot_device;
+	bootdev.boot_device = loader->boot_device;
 	bootdev.boot_device_name = NULL;
 
 	return loader->load_image(spl_image, &bootdev);
@@ -391,7 +391,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 		if (!loader)
 			puts("SPL: Unsupported Boot Device!\n");
 #endif
-		if (loader && !spl_load_image(spl_image, spl_boot_list[i]))
+		if (loader && !spl_load_image(spl_image, loader))
 			return 0;
 	}
 
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 5/8] spl: Drop announce_boot_device()
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
                   ` (3 preceding siblings ...)
  2016-11-17 17:29 ` [U-Boot] [PATCH 4/8] spl: Pass the loader into spl_load_image() Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 6/8] spl: sunxi: Drop spl_board_announce_boot_device() Simon Glass
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

This task can be handled by inline code now. Drop this function.

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

 common/spl/spl.c | 86 ++------------------------------------------------------
 1 file changed, 3 insertions(+), 83 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4555216..86474bb 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -267,87 +267,6 @@ __weak void board_boot_order(u32 *spl_boot_list)
 	spl_boot_list[0] = spl_boot_device();
 }
 
-#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
-__weak void spl_board_announce_boot_device(void) { }
-#endif
-
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-struct boot_device_name {
-	u32 boot_dev;
-	const char *name;
-};
-
-struct boot_device_name boot_name_table[] = {
-#ifdef CONFIG_SPL_RAM_DEVICE
-	{ BOOT_DEVICE_RAM, "RAM" },
-#endif
-#ifdef CONFIG_SPL_MMC_SUPPORT
-	{ BOOT_DEVICE_MMC1, "MMC1" },
-	{ BOOT_DEVICE_MMC2, "MMC2" },
-	{ BOOT_DEVICE_MMC2_2, "MMC2_2" },
-#endif
-#ifdef CONFIG_SPL_NAND_SUPPORT
-	{ BOOT_DEVICE_NAND, "NAND" },
-#endif
-#ifdef CONFIG_SPL_ONENAND_SUPPORT
-	{ BOOT_DEVICE_ONENAND, "OneNAND" },
-#endif
-#ifdef CONFIG_SPL_NOR_SUPPORT
-	{ BOOT_DEVICE_NOR, "NOR" },
-#endif
-#ifdef CONFIG_SPL_YMODEM_SUPPORT
-	{ BOOT_DEVICE_UART, "UART" },
-#endif
-#if defined(CONFIG_SPL_SPI_SUPPORT) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
-	{ BOOT_DEVICE_SPI, "SPI" },
-#endif
-#ifdef CONFIG_SPL_ETH_SUPPORT
-#ifdef CONFIG_SPL_ETH_DEVICE
-	{ BOOT_DEVICE_CPGMAC, "eth device" },
-#else
-	{ BOOT_DEVICE_CPGMAC, "net" },
-#endif
-#endif
-#ifdef CONFIG_SPL_USBETH_SUPPORT
-	{ BOOT_DEVICE_USBETH, "USB eth" },
-#endif
-#ifdef CONFIG_SPL_USB_SUPPORT
-	{ BOOT_DEVICE_USB, "USB" },
-#endif
-#ifdef CONFIG_SPL_DFU_SUPPORT
-	{ BOOT_DEVICE_DFU, "USB DFU" },
-#endif
-#ifdef CONFIG_SPL_SATA_SUPPORT
-	{ BOOT_DEVICE_SATA, "SATA" },
-#endif
-	/* Keep this entry last */
-	{ BOOT_DEVICE_NONE, "unknown boot device" },
-};
-
-static void announce_boot_device(u32 boot_device)
-{
-	int i;
-
-	puts("Trying to boot from ");
-
-#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
-	if (boot_device == BOOT_DEVICE_BOARD) {
-		spl_board_announce_boot_device();
-		puts("\n");
-		return;
-	}
-#endif
-	for (i = 0; i < ARRAY_SIZE(boot_name_table) - 1; i++) {
-		if (boot_name_table[i].boot_dev == boot_device)
-			break;
-	}
-
-	printf("%s\n", boot_name_table[i].name);
-}
-#else
-static inline void announce_boot_device(u32 boot_device) { }
-#endif
-
 static struct spl_image_loader *spl_ll_find_loader(uint boot_device)
 {
 	struct spl_image_loader *drv =
@@ -385,10 +304,11 @@ static int boot_from_devices(struct spl_image_info *spl_image,
 	     spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
 		struct spl_image_loader *loader;
 
-		announce_boot_device(spl_boot_list[i]);
 		loader = spl_ll_find_loader(spl_boot_list[i]);
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-		if (!loader)
+		if (loader)
+			printf("Trying to boot from %s", loader->name);
+		else
 			puts("SPL: Unsupported Boot Device!\n");
 #endif
 		if (loader && !spl_load_image(spl_image, loader))
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 6/8] spl: sunxi: Drop spl_board_announce_boot_device()
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
                   ` (4 preceding siblings ...)
  2016-11-17 17:29 ` [U-Boot] [PATCH 5/8] spl: Drop announce_boot_device() Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 7/8] spl: uniphier: " Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 8/8] spl: sandbox: " Simon Glass
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

This function is not used anymore. Drop it.

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

 arch/arm/mach-sunxi/board.c | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 205236d..aa11493 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -247,15 +247,6 @@ u32 spl_boot_device(void)
 	return -1;		/* Never reached */
 }
 
-/*
- * Properly announce BOOT_DEVICE_BOARD as "FEL".
- * Overrides weak function from common/spl/spl.c
- */
-void spl_board_announce_boot_device(void)
-{
-	printf("FEL");
-}
-
 /* No confirmation data available in SPL yet. Hardcode bootmode */
 u32 spl_boot_mode(const u32 boot_device)
 {
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 7/8] spl: uniphier: Drop spl_board_announce_boot_device()
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
                   ` (5 preceding siblings ...)
  2016-11-17 17:29 ` [U-Boot] [PATCH 6/8] spl: sunxi: Drop spl_board_announce_boot_device() Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  2016-11-17 17:29 ` [U-Boot] [PATCH 8/8] spl: sandbox: " Simon Glass
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

This function is not used anymore. Drop it.

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

 arch/arm/mach-uniphier/boot-mode/spl_board.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/arm/mach-uniphier/boot-mode/spl_board.c b/arch/arm/mach-uniphier/boot-mode/spl_board.c
index ba84087..a6b6686 100644
--- a/arch/arm/mach-uniphier/boot-mode/spl_board.c
+++ b/arch/arm/mach-uniphier/boot-mode/spl_board.c
@@ -12,11 +12,6 @@
 
 #include "../soc-info.h"
 
-void spl_board_announce_boot_device(void)
-{
-	printf("eMMC");
-}
-
 struct uniphier_romfunc_table {
 	void *mmc_send_cmd;
 	void *mmc_card_blockaddr;
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 8/8] spl: sandbox: Drop spl_board_announce_boot_device()
  2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
                   ` (6 preceding siblings ...)
  2016-11-17 17:29 ` [U-Boot] [PATCH 7/8] spl: uniphier: " Simon Glass
@ 2016-11-17 17:29 ` Simon Glass
  7 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-17 17:29 UTC (permalink / raw)
  To: u-boot

This function is not used anymore. Drop it.

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

 arch/sandbox/cpu/spl.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index 632446b..7cc76d4 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -25,19 +25,6 @@ u32 spl_boot_device(void)
 	return BOOT_DEVICE_BOARD;
 }
 
-void spl_board_announce_boot_device(void)
-{
-	char fname[256];
-	int ret;
-
-	ret = os_find_u_boot(fname, sizeof(fname));
-	if (ret) {
-		printf("(%s not found, error %d)\n", fname, ret);
-		return;
-	}
-	printf("%s\n", fname);
-}
-
 static int spl_board_load_image(struct spl_image_info *spl_image,
 				struct spl_boot_device *bootdev)
 {
@@ -45,8 +32,10 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 	int ret;
 
 	ret = os_find_u_boot(fname, sizeof(fname));
-	if (ret)
+	if (ret) {
+		printf("(%s not found, error %d)\n", fname, ret);
 		return ret;
+	}
 
 	/* Hopefully this will not return */
 	return os_spl_to_uboot(fname);
-- 
2.8.0.rc3.226.g39d4020

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function
  2016-11-17 17:29 ` [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function Simon Glass
@ 2016-11-22  7:31   ` Masahiro Yamada
  2016-11-28 20:09   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2016-11-22  7:31 UTC (permalink / raw)
  To: u-boot

Hi Simon,


2016-11-18 2:29 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Create a boot_from_devices() function to handle trying each device. This
> helps to reduce the size of the already-large board_init_r() function.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/spl/spl.c | 33 +++++++++++++++++++++------------
>  1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 4f23c0e..8c3a47d 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -372,12 +372,29 @@ static int spl_load_image(struct spl_image_info *spl_image, u32 boot_device)
>
>         bootdev.boot_device = boot_device;
>         bootdev.boot_device_name = NULL;
> -       if (loader)
> -               return loader->load_image(spl_image, &bootdev);
>
> +       return loader->load_image(spl_image, &bootdev);
> +}
> +
> +static int boot_from_devices(struct spl_image_info *spl_image,
> +                            u32 spl_boot_list[])
> +{
> +       int i;
> +
> +       for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
> +            spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
> +               struct spl_image_loader *loader;
> +
> +               announce_boot_device(spl_boot_list[i]);
> +               loader = spl_ll_find_loader(spl_boot_list[i]);


I do not believe ARRAY_SIZE(spl_boot_list) would work
in this context.




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot, 3/8] spl: Move the loading code into its own function
  2016-11-17 17:29 ` [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function Simon Glass
  2016-11-22  7:31   ` Masahiro Yamada
@ 2016-11-28 20:09   ` Tom Rini
  2016-11-28 20:19     ` Simon Glass
  1 sibling, 1 reply; 12+ messages in thread
From: Tom Rini @ 2016-11-28 20:09 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 17, 2016 at 10:29:30AM -0700, Simon Glass wrote:

> Create a boot_from_devices() function to handle trying each device. This
> helps to reduce the size of the already-large board_init_r() function.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

So with gcc-5.x and later:
+In file included from include/common.h:27:0,                                           +                 from common/spl/spl.c:9:                                              + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+                              ^
+common/spl/spl.c:384:18: note: in expansion of macro 'ARRAY_SIZE'
+  for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
+                  ^
+common/spl/spl.c:380:13: note: declared here
+         u32 spl_boot_list[])
+             ^
w+common/spl/spl.c: In function 'boot_from_devices':
w+include/linux/kernel.h:45:30: warning: 'sizeof' on array function parameter 'spl_boot_list' will return size of 'u32 * {aka unsigned int *}' [-Wsizeof-array-argument]

Which I think is what Masahiro was pointing out :)  So the rest of the
series needs some re-work following that too, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161128/f1a529a8/attachment.sig>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot, 3/8] spl: Move the loading code into its own function
  2016-11-28 20:09   ` [U-Boot] [U-Boot, " Tom Rini
@ 2016-11-28 20:19     ` Simon Glass
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2016-11-28 20:19 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On 28 November 2016 at 13:09, Tom Rini <trini@konsulko.com> wrote:
> On Thu, Nov 17, 2016 at 10:29:30AM -0700, Simon Glass wrote:
>
>> Create a boot_from_devices() function to handle trying each device. This
>> helps to reduce the size of the already-large board_init_r() function.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> So with gcc-5.x and later:
> +In file included from include/common.h:27:0,                                           +                 from common/spl/spl.c:9:                                              + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> +                              ^
> +common/spl/spl.c:384:18: note: in expansion of macro 'ARRAY_SIZE'
> +  for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
> +                  ^
> +common/spl/spl.c:380:13: note: declared here
> +         u32 spl_boot_list[])
> +             ^
> w+common/spl/spl.c: In function 'boot_from_devices':
> w+include/linux/kernel.h:45:30: warning: 'sizeof' on array function parameter 'spl_boot_list' will return size of 'u32 * {aka unsigned int *}' [-Wsizeof-array-argument]
>
> Which I think is what Masahiro was pointing out :)  So the rest of the
> series needs some re-work following that too, thanks!

Yes indeed, will get to it this week...need to test it properly with a
board with multiple loaders.

- Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-11-28 20:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17 17:29 [U-Boot] [PATCH 0/8] spl: Move image loader names into the linker list Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 1/8] spl: Use a single underscore in the SPL_LOAD_IMAGE_METHOD() macro Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 2/8] spl: Add a name to the SPL load-image methods Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 3/8] spl: Move the loading code into its own function Simon Glass
2016-11-22  7:31   ` Masahiro Yamada
2016-11-28 20:09   ` [U-Boot] [U-Boot, " Tom Rini
2016-11-28 20:19     ` Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 4/8] spl: Pass the loader into spl_load_image() Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 5/8] spl: Drop announce_boot_device() Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 6/8] spl: sunxi: Drop spl_board_announce_boot_device() Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 7/8] spl: uniphier: " Simon Glass
2016-11-17 17:29 ` [U-Boot] [PATCH 8/8] spl: sandbox: " Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox