mmc: sdhci-omap: Fix timeout checks
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 10 Dec 2018 08:56:25 +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>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci-omap.c

index f588ab679cb0b0363dee108530e14daa8c47cec6..ecf905066c56a3654e62171866034e081221f2e0 100644 (file)
@@ -221,8 +221,12 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host,
 
        /* wait 1ms */
        timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
-       while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) {
-               if (WARN_ON(ktime_after(ktime_get(), timeout)))
+       while (1) {
+               bool timedout = ktime_after(ktime_get(), timeout);
+
+               if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)
+                       break;
+               if (WARN_ON(timedout))
                        return;
                usleep_range(5, 10);
        }
@@ -655,8 +659,12 @@ static void sdhci_omap_init_74_clocks(struct sdhci_host *host, u8 power_mode)
 
        /* wait 1ms */
        timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT);
-       while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) {
-               if (WARN_ON(ktime_after(ktime_get(), timeout)))
+       while (1) {
+               bool timedout = ktime_after(ktime_get(), timeout);
+
+               if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)
+                       break;
+               if (WARN_ON(timedout))
                        return;
                usleep_range(5, 10);
        }