Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-android
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / core / host.c
index 2a3593d9f87df3bf01bb4229d74c5aef12ed3fdd..56dadd667ec1505bf81862cefea8e5fb6816897c 100644 (file)
@@ -459,6 +459,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 
        spin_lock_init(&host->lock);
        init_waitqueue_head(&host->wq);
+       wake_lock_init(&host->detect_wake_lock, WAKE_LOCK_SUSPEND,
+               kasprintf(GFP_KERNEL, "%s_detect", mmc_hostname(host)));
        INIT_DELAYED_WORK(&host->detect, mmc_rescan);
 #ifdef CONFIG_PM
        host->pm_notify.notifier_call = mmc_pm_notify;
@@ -511,7 +513,8 @@ int mmc_add_host(struct mmc_host *host)
        mmc_host_clk_sysfs_init(host);
 
        mmc_start_host(host);
-       register_pm_notifier(&host->pm_notify);
+       if (!(host->pm_flags & MMC_PM_IGNORE_PM_NOTIFY))
+               register_pm_notifier(&host->pm_notify);
 
        return 0;
 }
@@ -528,7 +531,9 @@ EXPORT_SYMBOL(mmc_add_host);
  */
 void mmc_remove_host(struct mmc_host *host)
 {
-       unregister_pm_notifier(&host->pm_notify);
+       if (!(host->pm_flags & MMC_PM_IGNORE_PM_NOTIFY))
+               unregister_pm_notifier(&host->pm_notify);
+
        mmc_stop_host(host);
 
 #ifdef CONFIG_DEBUG_FS
@@ -555,6 +560,7 @@ void mmc_free_host(struct mmc_host *host)
        spin_lock(&mmc_host_lock);
        idr_remove(&mmc_host_idr, host->index);
        spin_unlock(&mmc_host_lock);
+       wake_lock_destroy(&host->detect_wake_lock);
 
        put_device(&host->class_dev);
 }