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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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.

Signed-off-by: David Woodhouse <[hidden email]>
---
 drivers/mmc/mmc.c | 9 +++++++++
 env/fat.c         | 9 ---------
 env/mmc.c         | 9 ---------
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index d79cdef62e..11ce110df3 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -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
+}
diff --git a/env/fat.c b/env/fat.c
index 71bf8bfa18..653a38fd93 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -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
diff --git a/env/mmc.c b/env/mmc.c
index af7e5fbac3..4e67180b23 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -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)
 {
--
2.26.2

Reply | Threaded
Open this post in threaded view
|

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

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.

Signed-off-by: David Woodhouse <[hidden email]>
---
 env/Kconfig |  4 ++++
 env/ext4.c  | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

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)
--
2.26.2

Reply | Threaded
Open this post in threaded view
|

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

Tom Rini-4
In reply to this post by David Woodhouse
On Tue, Aug 04, 2020 at 10:05:46AM +0100, David Woodhouse wrote:

> 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.
>
> Signed-off-by: David Woodhouse <[hidden email]>

Applied to u-boot/master, thanks!

--
Tom

signature.asc (673 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Tom Rini-4
In reply to this post by David Woodhouse
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 <[hidden email]>

Applied to u-boot/master, thanks!

--
Tom

signature.asc (673 bytes) Download Attachment