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 <r64...@freescale.com>

Signed-off-by: Fabio Estevam <fabio.este...@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


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to