summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2019-07-02 10:53:58 +0200
committerPeng Fan <peng.fan@nxp.com>2019-07-15 10:16:49 +0800
commit0538477c53237230c36b78cfe5fa26aed81c9d87 (patch)
tree59a7feecf9ea94682d9b64512be724ef2007f411
parent9bc5666c8a32aa335b236fb3e140aa55766c7b03 (diff)
mmc: retry a few times if a partition switch failed
This operation may fail. Retry it a few times before giving up and report a failure. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
-rw-r--r--drivers/mmc/mmc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 709733747a..cec39a9acf 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -958,10 +958,14 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)
int mmc_switch_part(struct mmc *mmc, unsigned int part_num)
{
int ret;
+ int retry = 3;
- ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
- (mmc->part_config & ~PART_ACCESS_MASK)
- | (part_num & PART_ACCESS_MASK));
+ do {
+ ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_PART_CONF,
+ (mmc->part_config & ~PART_ACCESS_MASK)
+ | (part_num & PART_ACCESS_MASK));
+ } while (ret && retry--);
/*
* Set the capacity if the switch succeeded or was intended