diff mbox series

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

Message ID 20200804090547.2175076-2-dwmw2@infradead.org
State Accepted
Commit b0493bb75a4c5ab8c729dd714bc8a4b2e93eb35b
Delegated to: Tom Rini
Headers show
Series [1/2] mmc: remove duplicate mmc_get_env_dev() implementations | expand

Commit Message

David Woodhouse Aug. 4, 2020, 9:05 a.m. UTC
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.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
---
 env/Kconfig |  4 ++++
 env/ext4.c  | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Tom Rini Oct. 14, 2020, 5:42 p.m. UTC | #1
On Tue, Aug 04, 2020 at 10:05:47AM +0100, David Woodhouse wrote:

> 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.
> 
> Signed-off-by: David Woodhouse <dwmw2@infradead.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/env/Kconfig b/env/Kconfig
index 5d0a8ecea0..ae449ea92c 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -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
diff --git a/env/ext4.c b/env/ext4.c
index f823b69409..e666f7b945 100644
--- a/env/ext4.c
+++ b/env/ext4.c
@@ -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)