]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
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)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:36:30 +0000 (22:36 +0200)
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 b4404285a1d38a0f1a8943f389be5d2a664e7fd1..454a1d76c4be5b21f8b9fbca51778aed456a2acb 100644 (file)
@@ -399,22 +399,24 @@ static int mmc_complete_op_cond(struct mmc *mmc)
 {
        struct mmc_cmd cmd;
        int timeout = 1000;
-       uint start;
+       unsigned long start;
        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)
-                       break;
-               udelay(100);
-       } while (!(mmc->ocr & OCR_BUSY));
        if (!(mmc->ocr & OCR_BUSY)) {
-               debug("%s: timeout\n", __func__);
-               return UNUSABLE_ERR;
+               start = get_timer_masked();
+               do {
+                       err = mmc_send_op_cond_iter(mmc, 1);
+                       if (err)
+                               return err;
+                       udelay(100);
+                       if (get_timer(start) > timeout)
+                               break;
+               } while (!(mmc->ocr & OCR_BUSY));
+               if (!(mmc->ocr & OCR_BUSY)) {
+                       debug("%s: timeout\n", __func__);
+                       return UNUSABLE_ERR;
+               }
        }
 
        if (mmc_host_is_spi(mmc)) { /* read OCR for spi */
@@ -1660,7 +1662,7 @@ static int mmc_complete_init(struct mmc *mmc)
 int mmc_init(struct mmc *mmc)
 {
        int err = IN_PROGRESS;
-       unsigned start;
+       unsigned long start;
 
        if (mmc->has_init)
                return 0;