diff mbox series

[RESEND,1/3] env: mmc: allow support of mmc_get_env_dev with OF_CONTROL

Message ID 20200615103839.RESEND.1.Ib0b23085d678421d429580e13560b4dad27c9378@changeid
State Accepted
Commit 2b2f727500dc934ce201f1445c94c540ecae2798
Delegated to: Tom Rini
Headers show
Series env: mmc: allow support of mmc_get_env_dev with OF_CONTROL | expand

Commit Message

Patrick DELAUNAY June 15, 2020, 8:38 a.m. UTC
Use the weak function mmc_get_env_dev in mmc_offset_try_partition
function to allow dynamic selection of mmc device to use
and no more use directly the define CONFIG_SYS_MMC_ENV_DEV.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 env/mmc.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Tom Rini July 27, 2020, 1:33 p.m. UTC | #1
On Mon, Jun 15, 2020 at 10:38:55AM +0200, Patrick Delaunay wrote:

> Use the weak function mmc_get_env_dev in mmc_offset_try_partition
> function to allow dynamic selection of mmc device to use
> and no more use directly the define CONFIG_SYS_MMC_ENV_DEV.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

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

Patch

diff --git a/env/mmc.c b/env/mmc.c
index a8b661db80..e67ef90bce 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -24,14 +24,25 @@ 
 
 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, s64 *val)
 {
 	struct disk_partition info;
 	struct blk_desc *desc;
 	int len, i, ret;
+	char dev_str[4];
 
-	ret = blk_get_device_by_str("mmc", STR(CONFIG_SYS_MMC_ENV_DEV), &desc);
+	snprintf(dev_str, sizeof(dev_str), "%d", mmc_get_env_dev());
+	ret = blk_get_device_by_str("mmc", dev_str, &desc);
 	if (ret < 0)
 		return (ret);
 
@@ -114,11 +125,6 @@  __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
 	return 0;
 }
 
-__weak int mmc_get_env_dev(void)
-{
-	return CONFIG_SYS_MMC_ENV_DEV;
-}
-
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {