[U-Boot] [PATCH v2] mmc: Update "mmc->part_num" when performing a partition switch

Fabio Estevam fabio.estevam at freescale.com
Tue Jun 4 21:17:26 CEST 2013


When running the "save" command several times on a mx6qsabresd we see:

U-Boot > save
Saving Environment to MMC...
Writing to MMC(1)... done
U-Boot > save
Saving Environment to MMC...
MMC partition switch failed
U-Boot > save
Saving Environment to MMC...
Writing to MMC(1)... done
U-Boot > save
Saving Environment to MMC...
MMC partition switch failed
U-Boot > save
Saving Environment to MMC...
Writing to MMC(1)... done
U-Boot > save
Saving Environment to MMC...
MMC partition switch failed

Fix this by updating mmc->part_num inside mmc_switch_part() after a succesful
mmc partition switch.

After this fix, we no longer see the error after the "save" command on a 
mx6qsabresd. Also tested on a mx53loco.

Reported-by: Jason Liu <r64343 at freescale.com>

Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>
---
Changes since v1:
- Do the change inside the mmc core

 drivers/mmc/mmc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2590f1b..7f568ed 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -680,14 +680,20 @@ static int mmc_change_freq(struct mmc *mmc)
 
 int mmc_switch_part(int dev_num, unsigned int part_num)
 {
+	int ret;
 	struct mmc *mmc = find_mmc_device(dev_num);
 
 	if (!mmc)
 		return -1;
 
-	return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
+	ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
 			  (mmc->part_config & ~PART_ACCESS_MASK)
 			  | (part_num & PART_ACCESS_MASK));
+
+	if (!ret)
+		mmc->part_num = part_num;
+
+	return ret;
 }
 
 int mmc_getcd(struct mmc *mmc)
-- 
1.8.1.2




More information about the U-Boot mailing list