From 00120247b9a23550685df21331c868b7f4977794 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lothar=20Wa=C3=9Fmann?= Date: Thu, 22 Aug 2013 16:34:51 +0200 Subject: [PATCH] mmc: improve timeout loops to finally check the condition upon exiting the loop --- drivers/mmc/mmc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 0a7c9fa605..cc998b2039 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -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; -- 2.39.2