mmc: sdhci: specify maximum discard timeout
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 28 Jun 2011 14:16:03 +0000 (17:16 +0300)
committerChris Ball <cjb@laptop.org>
Wed, 20 Jul 2011 21:21:04 +0000 (17:21 -0400)
In general, SDHC hardware timeout cannot be avoided.
Accordingly, the maximum timeout is specified to limit
the maximum discard size.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/sdhci.c

index aa25eae65402898a20e598316e87b6fe2c589ff1..c31a3343340d34779b77c4a00b280da47b942816 100644 (file)
@@ -2509,6 +2509,11 @@ int sdhci_add_host(struct sdhci_host *host)
        } else
                mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
+       if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
+               mmc->max_discard_to = (1 << 27) / (mmc->f_max / 1000);
+       else
+               mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+
        mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
 
        if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12)