OSDN Git Service

Merge "mmc: core: Update SD card removal logic based on cd gpio state"
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / mmc / core / core.c
index 151643c..e4e4e04 100644 (file)
@@ -1883,10 +1883,9 @@ EXPORT_SYMBOL(mmc_start_req);
  */
 void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
 {
-#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
        if (mmc_bus_needs_resume(host))
                mmc_resume_bus(host);
-#endif
+
        __mmc_start_req(host, mrq);
        mmc_wait_for_req_done(host, mrq);
 }
@@ -2322,10 +2321,9 @@ void mmc_get_card(struct mmc_card *card)
 {
        pm_runtime_get_sync(&card->dev);
        mmc_claim_host(card->host);
-#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
+
        if (mmc_bus_needs_resume(card->host))
                mmc_resume_bus(card->host);
-#endif
 }
 EXPORT_SYMBOL(mmc_get_card);
 
@@ -3277,6 +3275,7 @@ int mmc_resume_bus(struct mmc_host *host)
 {
        unsigned long flags;
        int err = 0;
+       int card_present = true;
 
        if (!mmc_bus_needs_resume(host))
                return -EINVAL;
@@ -3287,7 +3286,10 @@ int mmc_resume_bus(struct mmc_host *host)
        spin_unlock_irqrestore(&host->lock, flags);
 
        mmc_bus_get(host);
-       if (host->bus_ops && !host->bus_dead && host->card) {
+       if (host->ops->get_cd)
+               card_present = host->ops->get_cd(host);
+
+       if (host->bus_ops && !host->bus_dead && host->card && card_present) {
                mmc_power_up(host, host->card->ocr);
                BUG_ON(!host->bus_ops->resume);
                err = host->bus_ops->resume(host);
@@ -4523,7 +4525,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
        struct mmc_host *host = container_of(
                notify_block, struct mmc_host, pm_notify);
        unsigned long flags;
-       int err = 0;
+       int err = 0, present = 0;
 
        switch (mode) {
        case PM_RESTORE_PREPARE:
@@ -4570,8 +4572,12 @@ int mmc_pm_notify(struct notifier_block *notify_block,
 
                spin_lock_irqsave(&host->lock, flags);
                host->rescan_disable = 0;
+               if (host->ops->get_cd)
+                       present = host->ops->get_cd(host);
+
                if (mmc_bus_manual_resume(host) &&
-                               !host->ignore_bus_resume_flags) {
+                               !host->ignore_bus_resume_flags &&
+                               present) {
                        spin_unlock_irqrestore(&host->lock, flags);
                        break;
                }