mmc: sdhci-of-esdhc: Fix timeout checks
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 10 Dec 2018 08:56:24 +0000 (10:56 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 17 Dec 2018 07:26:24 +0000 (08:26 +0100)
Always check the wait condition before returning timeout.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-of-esdhc.c

index e21e90f..4e669b4 100644 (file)
@@ -530,8 +530,12 @@ static void esdhc_clock_enable(struct sdhci_host *host, bool enable)
        /* Wait max 20 ms */
        timeout = ktime_add_ms(ktime_get(), 20);
        val = ESDHC_CLOCK_STABLE;
-       while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) {
-               if (ktime_after(ktime_get(), timeout)) {
+       while  (1) {
+               bool timedout = ktime_after(ktime_get(), timeout);
+
+               if (sdhci_readl(host, ESDHC_PRSSTAT) & val)
+                       break;
+               if (timedout) {
                        pr_err("%s: Internal clock never stabilised.\n",
                                mmc_hostname(host->mmc));
                        break;
@@ -639,8 +643,12 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
 
        /* Wait max 20 ms */
        timeout = ktime_add_ms(ktime_get(), 20);
-       while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) {
-               if (ktime_after(ktime_get(), timeout)) {
+       while (1) {
+               bool timedout = ktime_after(ktime_get(), timeout);
+
+               if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)
+                       break;
+               if (timedout) {
                        pr_err("%s: Internal clock never stabilised.\n",
                                mmc_hostname(host->mmc));
                        return;