summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schalig <dschalig@nvidia.com>2011-06-01 18:32:13 +0900
committerRohan Somvanshi <rsomvanshi@nvidia.com>2011-06-14 04:52:35 -0700
commitf5eae65898778526e7b7cdb63a575c0dd513ccf4 (patch)
treeadbd84a70bc57d5666143b8f364f1e0bc257e798
parentca3b85f97ea2ffb9a8ed4c4f434ebbc8bfcf2253 (diff)
mmc: fix card detect after suspend
If defered SD card resume (CONFIG_MMC_BLOCK_DEFERRED_RESUME) is enabled, PM_POST_SUSPEND handler will never set host->rescan_disable back to 0, and card detect logic will be disabled forever. fix missing break fix incorrect cleanup sequences Bug 833034 Change-Id: I91c8f657ee510f25180dc733d6106697d0e4498f Reviewed-on: http://git-master/r/36251 Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com> Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
-rw-r--r--drivers/mmc/core/bus.c1
-rw-r--r--drivers/mmc/core/core.c8
-rw-r--r--drivers/mmc/core/debugfs.c2
-rw-r--r--drivers/mmc/core/sd.c15
4 files changed, 14 insertions, 12 deletions
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 7cd9749dc21d..b2a89da738ea 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -248,6 +248,7 @@ int mmc_add_card(struct mmc_card *card)
type = "SD-combo";
if (mmc_card_blockaddr(card))
type = "SDHC-combo";
+ break;
default:
type = "?";
break;
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ad32bd77321f..4b72c2b7ab87 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -996,10 +996,10 @@ int mmc_resume_bus(struct mmc_host *host)
mmc_power_up(host);
BUG_ON(!host->bus_ops->resume);
host->bus_ops->resume(host);
- }
- if (host->bus_ops->detect && !host->bus_dead)
- host->bus_ops->detect(host);
+ if (host->bus_ops->detect)
+ host->bus_ops->detect(host);
+ }
mmc_bus_put(host);
printk("%s: Deferred resume completed\n", mmc_hostname(host));
@@ -1782,11 +1782,11 @@ int mmc_pm_notify(struct notifier_block *notify_block,
case PM_POST_RESTORE:
spin_lock_irqsave(&host->lock, flags);
+ host->rescan_disable = 0;
if (mmc_bus_manual_resume(host)) {
spin_unlock_irqrestore(&host->lock, flags);
break;
}
- host->rescan_disable = 0;
spin_unlock_irqrestore(&host->lock, flags);
mmc_detect_change(host, 0);
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 53cb380c0987..9e0c43e74461 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -164,6 +164,7 @@ err_root:
void mmc_remove_host_debugfs(struct mmc_host *host)
{
debugfs_remove_recursive(host->debugfs_root);
+ host->debugfs_root = NULL;
}
static int mmc_dbg_card_status_get(void *data, u64 *val)
@@ -290,4 +291,5 @@ err:
void mmc_remove_card_debugfs(struct mmc_card *card)
{
debugfs_remove_recursive(card->debugfs_root);
+ card->debugfs_root = NULL;
}
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 7ab8fdc61c77..b2f0f5d37fa9 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -605,7 +605,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (!mmc_host_is_spi(host)) {
err = mmc_send_relative_addr(host, &card->rca);
if (err)
- return err;
+ goto free_card;
mmc_set_bus_mode(host, MMC_BUSMODE_PUSHPULL);
}
@@ -613,7 +613,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (!oldcard) {
err = mmc_sd_get_csd(host, card);
if (err)
- return err;
+ goto free_card;
mmc_decode_cid(card);
}
@@ -624,7 +624,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
if (!mmc_host_is_spi(host)) {
err = mmc_select_card(card);
if (err)
- return err;
+ goto free_card;
}
err = mmc_sd_setup_card(host, card, oldcard != NULL);
@@ -672,11 +672,10 @@ free_card:
*/
static void mmc_sd_remove(struct mmc_host *host)
{
- BUG_ON(!host);
- BUG_ON(!host->card);
-
- mmc_remove_card(host->card);
- host->card = NULL;
+ if (host && host->card) {
+ mmc_remove_card(host->card);
+ host->card = NULL;
+ }
}
/*