diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-04-19 13:44:17 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-05-24 21:02:12 -0400 |
commit | 4b01681c77642c62a833187066c35e71e59caaf5 (patch) | |
tree | d9826b3bbd20c260cbff1cb4571c9518b784dab4 | |
parent | 24f5b53ba076e983bc64fa48534ca795d7813d51 (diff) |
mmc: sdhci: Fix SDHCI_QUIRK_TIMEOUT_USES_SDCLK
Commit 373e6a (mmc: sdhci: R1B command handling + MMC_CAP_ERASE) moved the
handling of SDHCI_QUIRK_TIMEOUT_USES_SDCLK from sdhci_calc_timeout() to
sdhci_add_host(). This causes division by zero errors on at least the S3C
SDHCI controller as the quirk implementation needs host->clock set to work
but host->clock has not been set when sdhci_add_host() is called.
Fix this by backing out that portion of the change, the clock may vary at
runtime anyway. It does occur to me that we may want to move the quirk to
where we set the clock but this seems more invasive and I'm concerned
about undesirable side effects.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Andrei Warkentin <andreiw@motorola.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/host/sdhci.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2ac0b6887ef7..4b97d5265526 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -616,6 +616,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) | |||
616 | target_timeout = data->timeout_ns / 1000 + | 616 | target_timeout = data->timeout_ns / 1000 + |
617 | data->timeout_clks / host->clock; | 617 | data->timeout_clks / host->clock; |
618 | 618 | ||
619 | if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) | ||
620 | host->timeout_clk = host->clock / 1000; | ||
621 | |||
619 | /* | 622 | /* |
620 | * Figure out needed cycles. | 623 | * Figure out needed cycles. |
621 | * We do this in steps in order to fit inside a 32 bit int. | 624 | * We do this in steps in order to fit inside a 32 bit int. |
@@ -626,6 +629,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) | |||
626 | * => | 629 | * => |
627 | * (1) / (2) > 2^6 | 630 | * (1) / (2) > 2^6 |
628 | */ | 631 | */ |
632 | BUG_ON(!host->timeout_clk); | ||
629 | count = 0; | 633 | count = 0; |
630 | current_timeout = (1 << 13) * 1000 / host->timeout_clk; | 634 | current_timeout = (1 << 13) * 1000 / host->timeout_clk; |
631 | while (current_timeout < target_timeout) { | 635 | while (current_timeout < target_timeout) { |
@@ -1901,9 +1905,6 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1901 | if (caps & SDHCI_TIMEOUT_CLK_UNIT) | 1905 | if (caps & SDHCI_TIMEOUT_CLK_UNIT) |
1902 | host->timeout_clk *= 1000; | 1906 | host->timeout_clk *= 1000; |
1903 | 1907 | ||
1904 | if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) | ||
1905 | host->timeout_clk = host->clock / 1000; | ||
1906 | |||
1907 | /* | 1908 | /* |
1908 | * Set host parameters. | 1909 | * Set host parameters. |
1909 | */ | 1910 | */ |