Commit 0e6e7c2f authored by Adrian Hunter's avatar Adrian Hunter Committed by Ulf Hansson

mmc: sdhci-xenon: Fix timeout checks

Always check the wait condition before returning timeout.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarZhoujie Wu <zjwu@marvell.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 9f0ea0bd
...@@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host) ...@@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host)
/* Wait max 32 ms */ /* Wait max 32 ms */
timeout = ktime_add_ms(ktime_get(), 32); timeout = ktime_add_ms(ktime_get(), 32);
while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) & while (1) {
XENON_DLL_LOCK_STATE)) { bool timedout = ktime_after(ktime_get(), timeout);
if (ktime_after(ktime_get(), timeout)) {
if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
XENON_DLL_LOCK_STATE)
break;
if (timedout) {
dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n"); dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
......
...@@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host) ...@@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host)
sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL); sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL);
/* Wait max 20 ms */ /* Wait max 20 ms */
timeout = ktime_add_ms(ktime_get(), 20); timeout = ktime_add_ms(ktime_get(), 20);
while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) while (1) {
& SDHCI_CLOCK_INT_STABLE)) { bool timedout = ktime_after(ktime_get(), timeout);
if (ktime_after(ktime_get(), timeout)) {
reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
if (reg & SDHCI_CLOCK_INT_STABLE)
break;
if (timedout) {
dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n"); dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment