mmc: sdhci: Return true only when timeout exceeds capacity of the HW timer
authorBean Huo <beanhuo@micron.com>
Fri, 17 Sep 2021 17:27:26 +0000 (19:27 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 12 Oct 2021 08:21:19 +0000 (10:21 +0200)
Clean up sdhci_calc_timeout() a bit,  and let it set too_big to be true only
when the timeout value required by the eMMC device exceeds the capability of
the host hardware timer.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20210917172727.26834-2-huobean@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci.c

index 7ae398f8d4d377e6e5f206dceee0e66606560d30..357b365bf0ec27868c91c1ffb18008fbd49e31d5 100644 (file)
@@ -930,7 +930,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        struct mmc_data *data;
        unsigned target_timeout, current_timeout;
 
-       *too_big = true;
+       *too_big = false;
 
        /*
         * If the host controller provides us with an incorrect timeout
@@ -941,7 +941,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
                return host->max_timeout_count;
 
-       /* Unspecified command, asume max */
+       /* Unspecified command, assume max */
        if (cmd == NULL)
                return host->max_timeout_count;
 
@@ -968,17 +968,14 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
        while (current_timeout < target_timeout) {
                count++;
                current_timeout <<= 1;
-               if (count > host->max_timeout_count)
+               if (count > host->max_timeout_count) {
+                       if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
+                               DBG("Too large timeout 0x%x requested for CMD%d!\n",
+                                   count, cmd->opcode);
+                       count = host->max_timeout_count;
+                       *too_big = true;
                        break;
-       }
-
-       if (count > host->max_timeout_count) {
-               if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
-                       DBG("Too large timeout 0x%x requested for CMD%d!\n",
-                           count, cmd->opcode);
-               count = host->max_timeout_count;
-       } else {
-               *too_big = false;
+               }
        }
 
        return count;