From 960ebf205a48d3abf8a037a2dd80420fc229bce2 Mon Sep 17 00:00:00 2001 From: Aaron Lu Date: Wed, 4 Jan 2012 10:07:43 +0800 Subject: mmc: sdhci: Deal with failure case in sdhci_suspend_host If there are errors happened in sdhci_suspend_host, handle it so that when the function returns with an error, the host's behaviour is the same before this function call, e.g. card detection is enabled and tuning timer is active, etc. Signed-off-by: Philip Rakity Signed-off-by: Aaron Lu Cc: Adrian Hunter Signed-off-by: Chris Ball (cherry picked from commit 38a60ea2e7b33ab33ee11d6ef527f259edb102cf) Bug 984811 Change-Id: I532c3914cecf63291a23baa669c650b4ac5448e4 Signed-off-by: Sang-Hun Lee Reviewed-on: http://git-master/r/106351 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Thomas Cherry Reviewed-by: Bitan Biswas --- drivers/mmc/host/sdhci.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'drivers/mmc/host') diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 495586924d60..22814660bc34 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2330,20 +2330,34 @@ out: int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state) { int ret = 0; + bool has_tuning_timer; struct mmc_host *mmc = host->mmc; sdhci_disable_card_detection(host); /* Disable tuning since we are suspending */ - if (host->version >= SDHCI_SPEC_300 && host->tuning_count && - host->tuning_mode == SDHCI_TUNING_MODE_1) { + has_tuning_timer = host->version >= SDHCI_SPEC_300 && + host->tuning_count && host->tuning_mode == SDHCI_TUNING_MODE_1; + if (has_tuning_timer) { host->flags &= ~SDHCI_NEEDS_RETUNING; mod_timer(&host->tuning_timer, jiffies + host->tuning_count * HZ); } - if (mmc->card) + if (mmc->card) { ret = mmc_suspend_host(host->mmc); + if (ret) { + if (has_tuning_timer) { + host->flags |= SDHCI_NEEDS_RETUNING; + mod_timer(&host->tuning_timer, jiffies + + host->tuning_count * HZ); + } + + sdhci_enable_card_detection(host); + + return ret; + } + } if (mmc->pm_flags & MMC_PM_KEEP_POWER) host->card_int_set = sdhci_readl(host, SDHCI_INT_ENABLE) & -- cgit v1.2.3