Skip to contentSkip to conversation

mmc: remove duplicate mmc_get_env_dev() implementations

PATCH New David Woodhouse 2 participants 4 messages Aug 4, 2020 – Oct 14, 2020 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mmc: remove duplicate mmc_get_env_dev() implementations

Since it's so trivial I could just about tolerate this when there were only two copies of it. But now there are about to be three.

---
 drivers/mmc/mmc.c | 9 +++++++++
 env/fat.c         | 9 ---------
 env/mmc.c         | 9 ---------
 3 files changed, 9 insertions(+), 18 deletions(-)
drivers/mmc/mmc.c +9 -0
index d79cdef62e..11ce110df3 100644
@@ -3111,3 +3111,12 @@ int mmc_set_bkops_enable(struct mmc *mmc)
 	return 0;
 }
 #endif
+
+__weak int mmc_get_env_dev(void)
+{
+#ifdef CONFIG_SYS_MMC_ENV_DEV
+	return CONFIG_SYS_MMC_ENV_DEV;
+#else
+	return 0;
+#endif
+}
env/fat.c +0 -9
index 71bf8bfa18..653a38fd93 100644
@@ -29,15 +29,6 @@
 # define LOADENV
 #endif
 
-__weak int mmc_get_env_dev(void)
-{
-#ifdef CONFIG_SYS_MMC_ENV_DEV
-	return CONFIG_SYS_MMC_ENV_DEV;
-#else
-	return 0;
-#endif
-}
-
 static char *env_fat_device_and_part(void)
 {
 #ifdef CONFIG_MMC
env/mmc.c +0 -9
index af7e5fbac3..4e67180b23 100644
@@ -24,15 +24,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if !defined(CONFIG_SYS_MMC_ENV_DEV)
-#define CONFIG_SYS_MMC_ENV_DEV 0
-#endif
-
-__weak int mmc_get_env_dev(void)
-{
-	return CONFIG_SYS_MMC_ENV_DEV;
-}
-
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 static inline int mmc_offset_try_partition(const char *str, int copy, s64 *val)
 {
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/2 env/ext4.c: allow loading from an EXT4 partition on the MMC boot device

This parallels what I added for FAT in commit 6731bef6966, allowing the environment to be found in a specific partition on the device that the board's mmc_get_env_dev() returns. On the Banana Pi R2 that means the device that U-Boot was loaded from; either the internal eMMC or an SD card.

---
 env/Kconfig |  4 ++++
 env/ext4.c  | 14 ++++++++++++++
 2 files changed, 18 insertions(+)
env/Kconfig +4 -0
index 5d0a8ecea0..ae449ea92c 100644
@@ -476,6 +476,10 @@ config ENV_EXT4_DEVICE_AND_PART
 	                   If none, first valid partition in device D. If no
 	                   partition table then means device D.
 
+	  If ENV_EXT4_INTERFACE is set to "mmc" then device 'D' can be omitted,
+	  leaving the string starting with a colon, and the boot device will
+	  be used.
+
 config ENV_EXT4_FILE
 	string "Name of the EXT4 file to use for the environment"
 	depends on ENV_IS_IN_EXT4
env/ext4.c +14 -0
index f823b69409..e666f7b945 100644
@@ -41,7 +41,21 @@ __weak const char *env_ext4_get_intf(void)
 
 __weak const char *env_ext4_get_dev_part(void)
 {
+#ifdef CONFIG_MMC
+	static char *part_str;
+
+	if (!part_str) {
+		part_str = CONFIG_ENV_EXT4_DEVICE_AND_PART;
+		if (!strcmp(CONFIG_ENV_EXT4_INTERFACE, "mmc") && part_str[0] == ':') {
+			part_str = "0" CONFIG_ENV_EXT4_DEVICE_AND_PART;
+			part_str[0] += mmc_get_env_dev();
+		}
+	}
+
+	return part_str;
+#else
 	return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART;
+#endif
 }
 
 static int env_ext4_save_buffer(env_t *env_new)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 env/ext4.c: allow loading from an EXT4 partition on the MMC boot device

Quoted 7 lines · David Woodhouse

This parallels what I added for FAT in commit 6731bef6966, allowing the environment to be found in a specific partition on the device that the board's mmc_get_env_dev() returns. On the Banana Pi R2 that means the device that U-Boot was loaded from; either the internal eMMC or an SD card.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201014/f582b11e/attachment.sig>
#3 lore raw

PATCH 1/2 mmc: remove duplicate mmc_get_env_dev() implementations

In reply to David Woodhouse
Quoted 4 lines · David Woodhouse

Since it's so trivial I could just about tolerate this when there were only two copies of it. But now there are about to be three.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201014/4d474312/attachment.sig>