mmc: retry a few times if a partition switch failed
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Tue, 2 Jul 2019 08:53:58 +0000 (10:53 +0200)
committerPeng Fan <peng.fan@nxp.com>
Mon, 15 Jul 2019 02:16:49 +0000 (10:16 +0800)
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>
drivers/mmc/mmc.c

index 709733747abcb896c064afb03edb74c7f608ad4c..cec39a9acf40730099d3a0cb6f6ef81d61270e9a 100644 (file)
@@ -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