mmc: core: Hold a wake lock accross delayed work + mmc rescan
San Mehat [Mon, 16 Apr 2012 07:21:26 +0000 (12:21 +0530)]
Signed-off-by: San Mehat <san@android.com>

mmc: core: Rework mmc_delayed_work wakelock so that the wakelock is only extended if a card is added or removed.

Signed-off-by: San Mehat <san@google.com>

Conflicts:

drivers/mmc/core/core.c

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>

drivers/mmc/core/core.c

index c91a800..4158477 100644 (file)
@@ -44,6 +44,7 @@
 #include "sdio_ops.h"
 
 static struct workqueue_struct *workqueue;
+static struct wake_lock mmc_delayed_work_wake_lock;
 
 /*
  * Enabling software CRCs on the data blocks can be a significant (30%)
@@ -76,6 +77,7 @@ MODULE_PARM_DESC(
 static int mmc_schedule_delayed_work(struct delayed_work *work,
                                     unsigned long delay)
 {
+       wake_lock(&mmc_delayed_work_wake_lock);
        return queue_delayed_work(workqueue, work, delay);
 }
 
@@ -2143,11 +2145,10 @@ void mmc_rescan(struct work_struct *work)
 
  out:
        if (extend_wakelock)
-               wake_lock_timeout(&host->detect_wake_lock, HZ / 2);
+               wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
        else
-               wake_unlock(&host->detect_wake_lock);
-       if (host->caps & MMC_CAP_NEEDS_POLL) {
-               wake_lock(&host->detect_wake_lock);
+               wake_unlock(&mmc_delayed_work_wake_lock);
+       if (host->caps & MMC_CAP_NEEDS_POLL)
                mmc_schedule_delayed_work(&host->detect, HZ);
        }
 }
@@ -2562,6 +2563,9 @@ static int __init mmc_init(void)
        if (!workqueue)
                return -ENOMEM;
 
+       wake_lock_init(&mmc_delayed_work_wake_lock, WAKE_LOCK_SUSPEND,
+                      "mmc_delayed_work");
+
        ret = mmc_register_bus();
        if (ret)
                goto destroy_workqueue;
@@ -2582,6 +2586,7 @@ unregister_bus:
        mmc_unregister_bus();
 destroy_workqueue:
        destroy_workqueue(workqueue);
+       wake_lock_destroy(&mmc_delayed_work_wake_lock);
 
        return ret;
 }
@@ -2592,6 +2597,7 @@ static void __exit mmc_exit(void)
        mmc_unregister_host_class();
        mmc_unregister_bus();
        destroy_workqueue(workqueue);
+       wake_lock_destroy(&mmc_delayed_work_wake_lock);
 }
 
 subsys_initcall(mmc_init);