mmc: sdhci: Deal with failure case in sdhci_suspend_host
PATCH v2 2/2 mmc: sdhci: Deal with failure case in sdhci_suspend_host
V2: Error processing code in sdhci_pci_suspend should not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.
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.
--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci.c +21 -6
@@ -2339,25 +2339,40 @@ out:int sdhci_suspend_host (struct sdhci_host *host) { -int ret; +int ret, has_tuning_timer;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) {del_timer_sync (&host->tuning_timer); host->flags &= ~SDHCI_NEEDS_RETUNING ; } ret =mmc_suspend_host (host->mmc);if (ret) -return ret; + goto err_suspend; + +if (host->vmmc) { + ret =regulator_disable (host->vmmc); +if (ret) + goto err_suspend; + }free_irq (host->irq, host); -if (host->vmmc) - ret =regulator_disable (host->vmmc); +return 0 ; + +err_suspend: +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; }
Signature · 1 line
1.7.7.4
Adrian Hunter
maintainerQuoted 39 lines · Aaron Lu
V2: Error processing code in
sdhci_pci_suspendshould not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.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<[email protected]>Signed-off-by Aaron Lu<[email protected]>Cc Adrian Hunter<[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)drivers/mmc/host/sdhci.c +4
-3@@ -2339,25 +2339,40 @@ out:int sdhci_suspend_host (struct sdhci_host *host) { -int ret; +int ret, has_tuning_timer;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) {del_timer_sync (&host->tuning_timer); host->flags&= ~SDHCI_NEEDS_RETUNING ; }
drivers/mmc/host/sdhci.c out: · line 2362
Quoted 10 lines
drivers/mmc/host/sdhci.c +7
-1ret =mmc_suspend_host (host->mmc);if (ret) -return ret; + goto err_suspend; + +if (host->vmmc) { + ret =regulator_disable (host->vmmc); +if (ret) + goto err_suspend; + }
This is slightly in conflict with my patch
"mmc: sdhci: fix vmmc handling"
Maybe you guys could ack/nack that
and adjust this accordingly.
Quoted 18 lines
drivers/mmc/host/sdhci.c +10
-2free_irq (host->irq, host); -if (host->vmmc) - ret =regulator_disable (host->vmmc); +return 0 ; + +err_suspend: +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; }
Hi Aaron,
Quoted 54 lines · Adrian Hunter
Quoted 39 lines · Aaron Lu
V2: Error processing code in
sdhci_pci_suspendshould not be deleted, it is used to resume hosts which are already successfully suspended for a multi slot pci device as suggested by Adrian.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<[email protected]>Signed-off-by Aaron Lu<[email protected]>Cc Adrian Hunter<[email protected]>--- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)drivers/mmc/host/sdhci.c +4
-3@@ -2339,25 +2339,40 @@ out:int sdhci_suspend_host (struct sdhci_host *host) { -int ret; +int ret, has_tuning_timer;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) {del_timer_sync (&host->tuning_timer); host->flags&= ~SDHCI_NEEDS_RETUNING ; }drivers/mmc/host/sdhci.c out: · line 2362
Quoted 10 lines
drivers/mmc/host/sdhci.c +7
-1ret =mmc_suspend_host (host->mmc);if (ret) -return ret; + goto err_suspend; + +if (host->vmmc) { + ret =regulator_disable (host->vmmc); +if (ret) + goto err_suspend; + }This is slightly in conflict with my patch
"mmc: sdhci: fix vmmc handling"
Quoted 2 lines
Maybe you guys could ack/nack that
and adjust this accordingly.
I've pushed Adrian's vmmc patch to mmc-next now, so this can be reworked.
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child