]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mmc: sdhci-xenon: Fix timeout checks
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 10 Dec 2018 08:56:26 +0000 (10:56 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837664
[ Upstream commit 0e6e7c2ff397e1bbebc882ca3132148aaaef1ddd ]

Always check the wait condition before returning timeout.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Zhoujie Wu <zjwu@marvell.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/mmc/host/sdhci-xenon-phy.c
drivers/mmc/host/sdhci-xenon.c

index ec87943352418056ad40b09bba05c0f3569ecbf6..82051f2b71918c8475be75801f6b1bdada99b819 100644 (file)
@@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host)
 
        /* Wait max 32 ms */
        timeout = ktime_add_ms(ktime_get(), 32);
-       while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) &
-               XENON_DLL_LOCK_STATE)) {
-               if (ktime_after(ktime_get(), timeout)) {
+       while (1) {
+               bool timedout = 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");
                        return -ETIMEDOUT;
                }
index 4d0791f6ec2368ee099a80b5a842c9e059770e54..a0b5089b3274821b6e84f16e57ffebd08a184cae 100644 (file)
@@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host)
        sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL);
        /* Wait max 20 ms */
        timeout = ktime_add_ms(ktime_get(), 20);
-       while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
-                       & SDHCI_CLOCK_INT_STABLE)) {
-               if (ktime_after(ktime_get(), timeout)) {
+       while (1) {
+               bool timedout = 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");
                        return -ETIMEDOUT;
                }