[U-Boot] [PATCH 06/12] spl: mmc: move fs boot into its own function

Nikita Kiryanov nikita at compulab.co.il
Thu Oct 22 14:01:14 CEST 2015


Move the code that handles fs boot out of spl_mmc_load_image() and into its
own function to reduce the #ifdef complexit of spl_mmc_load_image().

No functional changes.

Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
Cc: Igor Grinberg <grinberg at compulab.co.il>
Cc: Paul Kocialkowski <contact at paulk.fr>
Cc: Pantelis Antoniou <panto at antoniou-consulting.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: Simon Glass <sjg at chromium.org>
---
 common/spl/spl_mmc.c | 81 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 51 insertions(+), 30 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index fbdcf0d..959cdcc 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -171,6 +171,55 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 }
 #endif
 
+#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+	int err = -ENOSYS;
+
+#ifdef CONFIG_SPL_FAT_SUPPORT
+	if (!spl_start_uboot()) {
+		err = spl_load_image_fat_os(&mmc->block_dev,
+			CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+		if (!err)
+			return err;
+	}
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+	err = spl_load_image_fat(&mmc->block_dev,
+				 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+				 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+	if (!err)
+		return err;
+#endif
+#endif
+#ifdef CONFIG_SPL_EXT_SUPPORT
+	if (!spl_start_uboot()) {
+		err = spl_load_image_ext_os(&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,
+				 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+				 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+	if (!err)
+		return err;
+#endif
+#endif
+
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+	err = -ENOENT;
+#endif
+
+	return err;
+}
+#else
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+	return -ENOSYS;
+}
+#endif
+
 void spl_mmc_load_image(void)
 {
 	struct mmc *mmc;
@@ -214,38 +263,10 @@ void spl_mmc_load_image(void)
 	case MMCSD_MODE_FS:
 		debug("spl: mmc boot mode: fs\n");
 
-#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-#ifdef CONFIG_SPL_FAT_SUPPORT
-		if (!spl_start_uboot()) {
-			err = spl_load_image_fat_os(&mmc->block_dev,
-				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-			if (!err)
-				return;
-		}
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-		err = spl_load_image_fat(&mmc->block_dev,
-					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-					 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
-		if (!err)
-			return;
-#endif
-#endif
-#ifdef CONFIG_SPL_EXT_SUPPORT
-		if (!spl_start_uboot()) {
-			err = spl_load_image_ext_os(&mmc->block_dev,
-				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-			if (!err)
-				return;
-		}
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-		err = spl_load_image_ext(&mmc->block_dev,
-					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-					 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+		err = spl_mmc_do_fs_boot(mmc);
 		if (!err)
 			return;
-#endif
-#endif
-#endif
+
 		break;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 	case MMCSD_MODE_EMMCBOOT:
-- 
1.9.1



More information about the U-Boot mailing list