ANDROID: mmc: sd: When resuming, try a little harder to init the card
authorSan Mehat <san@android.com>
Mon, 1 Dec 2008 16:52:34 +0000 (08:52 -0800)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 18 Dec 2017 15:41:22 +0000 (21:11 +0530)
Signed-off-by: San Mehat <san@android.com>
drivers/mmc/core/sd.c

index e85524cc3659191bd8bd5feceac30d48a34e2f3b..2fb3a5f3adb29b414b644124ca4dd2591ef58e44 100644 (file)
@@ -1142,6 +1142,9 @@ static int mmc_sd_suspend(struct mmc_host *host)
 static int _mmc_sd_resume(struct mmc_host *host)
 {
        int err = 0;
+#ifdef CONFIG_MMC_PARANOID_SD_INIT
+       int retries;
+#endif
 
        mmc_claim_host(host);
 
@@ -1149,7 +1152,23 @@ static int _mmc_sd_resume(struct mmc_host *host)
                goto out;
 
        mmc_power_up(host, host->card->ocr);
+#ifdef CONFIG_MMC_PARANOID_SD_INIT
+       retries = 5;
+       while (retries) {
+               err = mmc_sd_init_card(host, host->card->ocr, host->card);
+
+               if (err) {
+                       printk(KERN_ERR "%s: Re-init card rc = %d (retries = %d)\n",
+                              mmc_hostname(host), err, retries);
+                       mdelay(5);
+                       retries--;
+                       continue;
+               }
+               break;
+       }
+#else
        err = mmc_sd_init_card(host, host->card->ocr, host->card);
+#endif
        mmc_card_clr_suspended(host->card);
 
 out: