From: Masahiro Yamada Date: Sat, 9 Jul 2016 15:40:22 +0000 (+0900) Subject: mmc: sdhci: clean up timeout detection X-Git-Tag: v2016.09-rc2~98^2~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bae4a1fdf59cddf02acd0070d1da7303fe5ffd0e;p=oweals%2Fu-boot.git mmc: sdhci: clean up timeout detection The current timeout detection logic is not very nice; it calls get_timer(start) in the while() loop, and then calls it again after the loop to check if a timeout error happened. Because of the time difference between the two calls of get_timer(), the timeout detected after the loop may not be true. Signed-off-by: Masahiro Yamada Acked-by: Jaehoon Chung Signed-off-by: Jaehoon Chung --- diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 9fdbed8aa9..1de1f8ea01 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -252,17 +252,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, stat = sdhci_readl(host, SDHCI_INT_STATUS); if (stat & SDHCI_INT_ERROR) break; - } while (((stat & mask) != mask) && - (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT)); - if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { - if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) - return 0; - else { - printf("%s: Timeout for status update!\n", __func__); - return TIMEOUT; + if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { + if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) { + return 0; + } else { + printf("%s: Timeout for status update!\n", + __func__); + return TIMEOUT; + } } - } + } while ((stat & mask) != mask); if ((stat & (SDHCI_INT_ERROR | mask)) == mask) { sdhci_cmd_done(host, cmd);