Commit cc17c01f2d3b691ddadbd46727d5f22db0a90808
Committed by
Pantelis Antoniou
1 parent
5289b5350b
Exists in
v2017.01-smarct4x
and in
34 other branches
mmc: Continue polling MMC card for OCR only if it is still not ready
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>
Showing 1 changed file with 11 additions and 9 deletions Side-by-side Diff
drivers/mmc/mmc.c
... | ... | @@ -403,15 +403,17 @@ |
403 | 403 | int err; |
404 | 404 | |
405 | 405 | mmc->op_cond_pending = 0; |
406 | - start = get_timer(0); | |
407 | - do { | |
408 | - err = mmc_send_op_cond_iter(mmc, 1); | |
409 | - if (err) | |
410 | - return err; | |
411 | - if (get_timer(start) > timeout) | |
412 | - return UNUSABLE_ERR; | |
413 | - udelay(100); | |
414 | - } while (!(mmc->ocr & OCR_BUSY)); | |
406 | + if (!(mmc->ocr & OCR_BUSY)) { | |
407 | + start = get_timer(0); | |
408 | + do { | |
409 | + err = mmc_send_op_cond_iter(mmc, 1); | |
410 | + if (err) | |
411 | + return err; | |
412 | + if (get_timer(start) > timeout) | |
413 | + return UNUSABLE_ERR; | |
414 | + udelay(100); | |
415 | + } while (!(mmc->ocr & OCR_BUSY)); | |
416 | + } | |
415 | 417 | |
416 | 418 | if (mmc_host_is_spi(mmc)) { /* read OCR for spi */ |
417 | 419 | cmd.cmdidx = MMC_CMD_SPI_READ_OCR; |