diff options
author | Simon Glass | 2016-09-24 18:19:57 -0600 |
---|---|---|
committer | Tom Rini | 2016-10-06 14:53:36 -0400 |
commit | ecdfd69a4be55363589e8185ff151b02e6c36cfa (patch) | |
tree | b625ae78bfe96236f62320061a1a667f4d8e446d /common | |
parent | a807ab33035fe2e9b63aac2e7475525ca8d90adc (diff) |
spl: Convert boot_device into a struct
At present some spl_xxx_load_image() functions take a parameter and some
don't. Of those that do, most take an integer but one takes a string.
Convert this parameter into a struct so that we can pass all functions the
same thing. This will allow us to use a common function signature.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl.c | 39 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 6 | ||||
-rw-r--r-- | common/spl/spl_nand.c | 2 | ||||
-rw-r--r-- | common/spl/spl_net.c | 6 | ||||
-rw-r--r-- | common/spl/spl_nor.c | 2 | ||||
-rw-r--r-- | common/spl/spl_onenand.c | 2 | ||||
-rw-r--r-- | common/spl/spl_sata.c | 2 | ||||
-rw-r--r-- | common/spl/spl_ubi.c | 6 | ||||
-rw-r--r-- | common/spl/spl_usb.c | 2 | ||||
-rw-r--r-- | common/spl/spl_ymodem.c | 2 |
10 files changed, 37 insertions, 32 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c index 6d071312bc5..167bff07f9d 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -185,7 +185,7 @@ static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector, return count; } -static int spl_ram_load_image(void) +static int spl_ram_load_image(struct spl_boot_device *bootdev) { struct image_header *header; @@ -349,71 +349,76 @@ static inline void announce_boot_device(u32 boot_device) { } static int spl_load_image(u32 boot_device) { + struct spl_boot_device bootdev; + + bootdev.boot_device = boot_device; + bootdev.boot_device_name = NULL; + switch (boot_device) { #ifdef CONFIG_SPL_RAM_DEVICE case BOOT_DEVICE_RAM: - return spl_ram_load_image(); + return spl_ram_load_image(&bootdev); #endif #ifdef CONFIG_SPL_MMC_SUPPORT case BOOT_DEVICE_MMC1: case BOOT_DEVICE_MMC2: case BOOT_DEVICE_MMC2_2: - return spl_mmc_load_image(boot_device); + return spl_mmc_load_image(&bootdev); #endif #ifdef CONFIG_SPL_UBI case BOOT_DEVICE_NAND: case BOOT_DEVICE_ONENAND: - return spl_ubi_load_image(boot_device); + return spl_ubi_load_image(&bootdev); #else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND: - return spl_nand_load_image(); + return spl_nand_load_image(&bootdev); #endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND: - return spl_onenand_load_image(); + return spl_onenand_load_image(&bootdev); #endif #endif #ifdef CONFIG_SPL_NOR_SUPPORT case BOOT_DEVICE_NOR: - return spl_nor_load_image(); + return spl_nor_load_image(&bootdev); #endif #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART: - return spl_ymodem_load_image(); + return spl_ymodem_load_image(&bootdev); #endif #if defined(CONFIG_SPL_SPI_SUPPORT) || defined(CONFIG_SPL_SPI_FLASH_SUPPORT) case BOOT_DEVICE_SPI: - return spl_spi_load_image(); + return spl_spi_load_image(&bootdev); #endif #ifdef CONFIG_SPL_ETH_SUPPORT case BOOT_DEVICE_CPGMAC: #ifdef CONFIG_SPL_ETH_DEVICE - return spl_net_load_image(CONFIG_SPL_ETH_DEVICE); -#else - return spl_net_load_image(NULL); + bootdev.boot_device_name = CONFIG_SPL_ETH_DEVICE; #endif + return spl_net_load_image(&bootdev); #endif #ifdef CONFIG_SPL_USBETH_SUPPORT case BOOT_DEVICE_USBETH: - return spl_net_load_image("usb_ether"); + bootdev.boot_device_name = "usb_ether"; + return spl_net_load_image(&bootdev); #endif #ifdef CONFIG_SPL_USB_SUPPORT case BOOT_DEVICE_USB: - return spl_usb_load_image(); + return spl_usb_load_image(&bootdev); #endif #ifdef CONFIG_SPL_DFU_SUPPORT case BOOT_DEVICE_DFU: spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0"); - return spl_ram_load_image(); + return spl_ram_load_image(&bootdev); #endif #ifdef CONFIG_SPL_SATA_SUPPORT case BOOT_DEVICE_SATA: - return spl_sata_load_image(); + return spl_sata_load_image(&bootdev); #endif #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE case BOOT_DEVICE_BOARD: - return spl_board_load_image(); + return spl_board_load_image(&bootdev); #endif default: #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 97c11b37f66..899caf4a9b5 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -267,14 +267,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc) } #endif -int spl_mmc_load_image(u32 boot_device) +int spl_mmc_load_image(struct spl_boot_device *bootdev) { struct mmc *mmc = NULL; u32 boot_mode; int err = 0; __maybe_unused int part; - err = spl_mmc_find_device(&mmc, boot_device); + err = spl_mmc_find_device(&mmc, bootdev->boot_device); if (err) return err; @@ -286,7 +286,7 @@ int spl_mmc_load_image(u32 boot_device) return err; } - boot_mode = spl_boot_mode(boot_device); + boot_mode = spl_boot_mode(bootdev->boot_device); err = -EINVAL; switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index f25220f1721..575de661d39 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -13,7 +13,7 @@ #include <fdt.h> #if defined(CONFIG_SPL_NAND_RAW_ONLY) -int spl_nand_load_image(void) +int spl_nand_load_image(struct spl_boot_device *bootdev) { nand_init(); diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index f417d177eb1..730f88e0d60 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -14,7 +14,7 @@ DECLARE_GLOBAL_DATA_PTR; -int spl_net_load_image(const char *device) +int spl_net_load_image(struct spl_boot_device *bootdev) { int rv; @@ -27,8 +27,8 @@ int spl_net_load_image(const char *device) printf("No Ethernet devices found\n"); return -ENODEV; } - if (device) - setenv("ethact", device); + if (bootdev->boot_device_name) + setenv("ethact", bootdev->boot_device_name); rv = net_loop(BOOTP); if (rv < 0) { printf("Problem booting with BOOTP\n"); diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index 57771e8f578..f10d679922f 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -7,7 +7,7 @@ #include <common.h> #include <spl.h> -int spl_nor_load_image(void) +int spl_nor_load_image(struct spl_boot_device *bootdev) { int ret; /* diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c index 8d2c51bc479..f5e2f95b13e 100644 --- a/common/spl/spl_onenand.c +++ b/common/spl/spl_onenand.c @@ -14,7 +14,7 @@ #include <asm/io.h> #include <onenand_uboot.h> -int spl_onenand_load_image(void) +int spl_onenand_load_image(struct spl_boot_device *bootdev) { struct image_header *header; int ret; diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index 9d8cc7c2ddf..77fd73c9893 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -20,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR; -int spl_sata_load_image(void) +int spl_sata_load_image(struct spl_boot_device *bootdev) { int err; struct blk_desc *stor_dev; diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index 5198babaae3..d64e6cf57d1 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -12,14 +12,14 @@ #include <ubispl.h> #include <spl.h> -int spl_ubi_load_image(u32 boot_device) +int spl_ubi_load_image(struct spl_boot_device *bootdev) { struct image_header *header; struct ubispl_info info; struct ubispl_load volumes[2]; int ret = 1; - switch (boot_device) { + switch (bootdev->boot_device) { #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND: nand_init(); @@ -71,7 +71,7 @@ int spl_ubi_load_image(u32 boot_device) spl_parse_image_header(&spl_image, header); out: #ifdef CONFIG_SPL_NAND_SUPPORT - if (boot_device == BOOT_DEVICE_NAND) + if (bootdev->boot_device == BOOT_DEVICE_NAND) nand_deselect(); #endif return ret; diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c index 04fa66758cb..f990336a3c4 100644 --- a/common/spl/spl_usb.c +++ b/common/spl/spl_usb.c @@ -22,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR; static int usb_stor_curr_dev = -1; /* current device */ #endif -int spl_usb_load_image(void) +int spl_usb_load_image(struct spl_boot_device *bootdev) { int err; struct blk_desc *stor_dev; diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 1323b6f028f..d82b138568a 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -68,7 +68,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset, return size; } -int spl_ymodem_load_image(void) +int spl_ymodem_load_image(struct spl_boot_device *bootdev) { int size = 0; int err; |