]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - drivers/mmc/mmc.c
mmc: Retry the switch command
[people/ms/u-boot.git] / drivers / mmc / mmc.c
index 4380c7c195a628e343f1f0b4719be6b6bbf3fdb3..d6b7e4f510c93c3faadaa6b84646bc7402e68b1b 100644 (file)
@@ -494,6 +494,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 {
        struct mmc_cmd cmd;
        int timeout = 1000;
+       int retries = 3;
        int ret;
 
        cmd.cmdidx = MMC_CMD_SWITCH;
@@ -502,11 +503,17 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
                                 (index << 16) |
                                 (value << 8);
 
-       ret = mmc_send_cmd(mmc, &cmd, NULL);
+       while (retries > 0) {
+               ret = mmc_send_cmd(mmc, &cmd, NULL);
 
-       /* Waiting for the ready status */
-       if (!ret)
-               ret = mmc_send_status(mmc, timeout);
+               /* Waiting for the ready status */
+               if (!ret) {
+                       ret = mmc_send_status(mmc, timeout);
+                       return ret;
+               }
+
+               retries--;
+       }
 
        return ret;