mmc: Continue polling MMC card for OCR only if it is still not ready
authorAndrew Gabbasov <andrew_gabbasov@mentor.com>
Thu, 19 Mar 2015 12:44:05 +0000 (07:44 -0500)
committerPantelis Antoniou <pantelis.antoniou@konsulko.com>
Tue, 5 May 2015 08:54:40 +0000 (11:54 +0300)
Some MMC cards come to ready state quite quickly, so that the respective
flag appears to be set in mmc_send_op_cond already. In this case trying
to continue polling the card with CMD1 in mmc_complete_op_cond is incorrect
and may lead to unpredictable results. So check the flag before polling
and skip it appropriately.

Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
drivers/mmc/mmc.c

index d073d7900c36ff03d9f54d440828c0e7bb97ca5c..42af47c4c27372fc6e896c91ed2ae2288c013a7a 100644 (file)
@@ -403,15 +403,17 @@ static int mmc_complete_op_cond(struct mmc *mmc)
        int err;
 
        mmc->op_cond_pending = 0;
-       start = get_timer(0);
-       do {
-               err = mmc_send_op_cond_iter(mmc, 1);
-               if (err)
-                       return err;
-               if (get_timer(start) > timeout)
-                       return UNUSABLE_ERR;
-               udelay(100);
-       } while (!(mmc->ocr & OCR_BUSY));
+       if (!(mmc->ocr & OCR_BUSY)) {
+               start = get_timer(0);
+               do {
+                       err = mmc_send_op_cond_iter(mmc, 1);
+                       if (err)
+                               return err;
+                       if (get_timer(start) > timeout)
+                               return UNUSABLE_ERR;
+                       udelay(100);
+               } while (!(mmc->ocr & OCR_BUSY));
+       }
 
        if (mmc_host_is_spi(mmc)) { /* read OCR for spi */
                cmd.cmdidx = MMC_CMD_SPI_READ_OCR;