public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] mmc: Update "mmc->part_num" when performing a partition switch
@ 2013-06-04 19:17 Fabio Estevam
  2013-06-04 19:21 ` Stephen Warren
  0 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2013-06-04 19:17 UTC (permalink / raw)
  To: u-boot

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

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-06-04 23:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04 19:17 [U-Boot] [PATCH v2] mmc: Update "mmc->part_num" when performing a partition switch Fabio Estevam
2013-06-04 19:21 ` Stephen Warren
2013-06-04 19:30   ` Fabio Estevam
2013-06-04 19:36     ` Stephen Warren
2013-06-04 20:45       ` Fabio Estevam
2013-06-04 22:12         ` Stephen Warren
2013-06-04 23:09           ` Fabio Estevam
2013-06-04 23:30             ` Stephen Warren
2013-06-04 23:48               ` Fabio Estevam
2013-06-04 23:16           ` Fabio Estevam
2013-06-04 23:31             ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox