]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mmc: improve timeout loops to finally check the condition upon exiting the loop
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 22 Aug 2013 14:34:51 +0000 (16:34 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 22 Aug 2013 14:34:51 +0000 (16:34 +0200)
drivers/mmc/mmc.c

index 0a7c9fa6057cca4fd89e2175fb31671da82dd055..cc998b2039c3dcfae2e4f36044bf9cfb40599d21 100644 (file)
@@ -485,8 +485,7 @@ static int sd_send_op_cond(struct mmc *mmc)
 
                udelay(1000);
        } while ((!(cmd.response[0] & OCR_BUSY)) && timeout--);
-
-       if (timeout <= 0)
+       if (!(cmd.response[0] & OCR_BUSY))
                return UNUSABLE_ERR;
 
        if (mmc->version != SD_VERSION_2)
@@ -572,9 +571,13 @@ int mmc_complete_op_cond(struct mmc *mmc)
                if (err)
                        return err;
                if (get_timer(start) > timeout)
-                       return UNUSABLE_ERR;
+                       break;
                udelay(100);
        } while (!(mmc->op_cond_response & OCR_BUSY));
+       if (!(mmc->op_cond_response & OCR_BUSY)) {
+               debug("%s: timeout\n", __func__);
+               return UNUSABLE_ERR;
+       }
 
        if (mmc_host_is_spi(mmc)) { /* read OCR for spi */
                cmd.cmdidx = MMC_CMD_SPI_READ_OCR;