1. Tuning success at 40th time should be ok, but current code take this as failed. 2. tuning_count equals to 0 means disable retuning function, but current code still do retuning. Signed-off-by: peter.guo <peter.guo@xxxxxxxxxxxxxx> --- drivers/mmc/host/sdhci.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 68b3cac..9a35a5e 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1900,7 +1900,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) * Issue CMD19 repeatedly till Execute Tuning is set to 0 or the number * of loops reaches 40 times or a timeout of 150ms occurs. */ - timeout = jiffies + msecs_to_jiffies(150); +z timeout = jiffies + msecs_to_jiffies(150); do { struct mmc_command cmd = {0}; struct mmc_request mrq = {NULL}; @@ -1983,7 +1983,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) * The Host Driver has exhausted the maximum number of loops allowed, * so use fixed sampling frequency. */ - if (!tuning_loop_counter || time_after(jiffies, timeout)) { + if ((tuning_loop_counter < 0) || time_after(jiffies, timeout)) { ctrl &= ~SDHCI_CTRL_TUNED_CLK; sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); err = -EIO; @@ -2013,7 +2013,8 @@ out: } else { host->flags &= ~SDHCI_NEEDS_RETUNING; /* Reload the new initial value for timeout workqueue */ - if (host->tuning_mode == SDHCI_TUNING_MODE_1) + if ((host->tuning_mode == SDHCI_TUNING_MODE_1) && + (host->tuning_count)) schedule_delayed_work(&host->tuning_timeout_work, host->tuning_count * HZ); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html