mmc: sdhci: calculate timeout_clk conditionally in sdhci_add_host
authorAisheng Dong <b29396@freescale.com>
Wed, 27 Aug 2014 07:26:31 +0000 (15:26 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 9 Sep 2014 11:59:22 +0000 (13:59 +0200)
The timeout_clk calculation code in sdhci_add_host is meaningless for
SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK.
So only execute them with no SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK set.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sdhci.c

index ff0e1c55d95836b3706b8f17007d19dd62430e8b..1e50880d57de46375c71d30e6c7f3d7bbcd3760a 100644 (file)
@@ -2931,27 +2931,27 @@ int sdhci_add_host(struct sdhci_host *host)
        } else
                mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
-       host->timeout_clk =
-               (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
-       if (host->timeout_clk == 0) {
-               if (host->ops->get_timeout_clock) {
-                       host->timeout_clk = host->ops->get_timeout_clock(host);
-               } else if (!(host->quirks &
-                               SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
-                       pr_err("%s: Hardware doesn't specify timeout clock "
-                              "frequency.\n", mmc_hostname(mmc));
-                       return -ENODEV;
+       if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
+               host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >>
+                                       SDHCI_TIMEOUT_CLK_SHIFT;
+               if (host->timeout_clk == 0) {
+                       if (host->ops->get_timeout_clock) {
+                               host->timeout_clk =
+                                       host->ops->get_timeout_clock(host);
+                       } else {
+                               pr_err("%s: Hardware doesn't specify timeout clock frequency.\n",
+                                       mmc_hostname(mmc));
+                               return -ENODEV;
+                       }
                }
-       }
-       if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
-               host->timeout_clk *= 1000;
 
-       if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
-               host->timeout_clk = mmc->f_max / 1000;
+               if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
+                       host->timeout_clk *= 1000;
 
-       mmc->max_busy_timeout = host->ops->get_max_timeout_count ?
+               mmc->max_busy_timeout = host->ops->get_max_timeout_count ?
                        host->ops->get_max_timeout_count(host) : 1 << 27;
-       mmc->max_busy_timeout /= host->timeout_clk;
+               mmc->max_busy_timeout /= host->timeout_clk;
+       }
 
        mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
        mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;