diff options
| -rw-r--r-- | drivers/mmc/host/sdhci.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c45beaff1ab5..5c28c19622e6 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
| @@ -1885,10 +1885,14 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) | |||
| 1885 | int tuning_loop_counter = MAX_TUNING_LOOP; | 1885 | int tuning_loop_counter = MAX_TUNING_LOOP; |
| 1886 | int err = 0; | 1886 | int err = 0; |
| 1887 | unsigned long flags; | 1887 | unsigned long flags; |
| 1888 | unsigned int tuning_count = 0; | ||
| 1888 | 1889 | ||
| 1889 | sdhci_runtime_pm_get(host); | 1890 | sdhci_runtime_pm_get(host); |
| 1890 | spin_lock_irqsave(&host->lock, flags); | 1891 | spin_lock_irqsave(&host->lock, flags); |
| 1891 | 1892 | ||
| 1893 | if (host->tuning_mode == SDHCI_TUNING_MODE_1) | ||
| 1894 | tuning_count = host->tuning_count; | ||
| 1895 | |||
| 1892 | /* | 1896 | /* |
| 1893 | * The Host Controller needs tuning only in case of SDR104 mode | 1897 | * The Host Controller needs tuning only in case of SDR104 mode |
| 1894 | * and for SDR50 mode when Use Tuning for SDR50 is set in the | 1898 | * and for SDR50 mode when Use Tuning for SDR50 is set in the |
| @@ -2033,22 +2037,11 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) | |||
| 2033 | } | 2037 | } |
| 2034 | 2038 | ||
| 2035 | out: | 2039 | out: |
| 2036 | /* | 2040 | host->flags &= ~SDHCI_NEEDS_RETUNING; |
| 2037 | * If this is the very first time we are here, we start the retuning | 2041 | |
| 2038 | * timer. Since only during the first time, SDHCI_NEEDS_RETUNING | 2042 | if (tuning_count) { |
| 2039 | * flag won't be set, we check this condition before actually starting | ||
| 2040 | * the timer. | ||
| 2041 | */ | ||
| 2042 | if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count && | ||
| 2043 | (host->tuning_mode == SDHCI_TUNING_MODE_1)) { | ||
| 2044 | host->flags |= SDHCI_USING_RETUNING_TIMER; | 2043 | host->flags |= SDHCI_USING_RETUNING_TIMER; |
| 2045 | mod_timer(&host->tuning_timer, jiffies + | 2044 | mod_timer(&host->tuning_timer, jiffies + tuning_count * HZ); |
| 2046 | host->tuning_count * HZ); | ||
| 2047 | } else if (host->flags & SDHCI_USING_RETUNING_TIMER) { | ||
| 2048 | host->flags &= ~SDHCI_NEEDS_RETUNING; | ||
| 2049 | /* Reload the new initial value for timer */ | ||
| 2050 | mod_timer(&host->tuning_timer, jiffies + | ||
| 2051 | host->tuning_count * HZ); | ||
| 2052 | } | 2045 | } |
| 2053 | 2046 | ||
| 2054 | /* | 2047 | /* |
