mmc: core: host: only use wakelock for detect work
Colin Cross [Mon, 16 Apr 2012 07:25:58 +0000 (12:25 +0530)]
There is no need to take a wakelock for delayed lazy disable
work, it will be cancelled in the suspend handler and force
disabled.  Only take the wakelock when the detect work is
queued, and make sure to drop the wakelock if the work is
cancelled.

Change-Id: I1e507a5f98848954ea21d45e23b6192c3132a349
Signed-off-by: Colin Cross <ccross@android.com>

Conflicts:

drivers/mmc/core/core.c

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

drivers/mmc/core/core.c

index dbb6d6f..67631cc 100644 (file)
@@ -44,7 +44,6 @@
 #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%)
@@ -77,7 +76,6 @@ 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);
 }
 
@@ -2145,10 +2143,11 @@ void mmc_rescan(struct work_struct *work)
 
  out:
        if (extend_wakelock)
-               wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
+               wake_lock_timeout(&host->detect_wake_lock, HZ / 2);
        else
-               wake_unlock(&mmc_delayed_work_wake_lock);
-       if (host->caps & MMC_CAP_NEEDS_POLL)
+               wake_unlock(&host->detect_wake_lock);
+       if (host->caps & MMC_CAP_NEEDS_POLL) {
+               wake_lock(&host->detect_wake_lock);
                mmc_schedule_delayed_work(&host->detect, HZ);
        }
 }
@@ -2370,7 +2369,8 @@ int mmc_suspend_host(struct mmc_host *host)
                mmc_interrupt_hpi(host->card);
        mmc_card_clr_need_bkops(host->card);
 
-       cancel_delayed_work(&host->detect);
+       if (cancel_delayed_work(&host->detect))
+               wake_unlock(&host->detect_wake_lock);
        mmc_flush_scheduled_work();
        if (mmc_try_claim_host(host)) {
                err = mmc_cache_ctrl(host, 0);
@@ -2561,9 +2561,6 @@ 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;
@@ -2584,7 +2581,6 @@ unregister_bus:
        mmc_unregister_bus();
 destroy_workqueue:
        destroy_workqueue(workqueue);
-       wake_lock_destroy(&mmc_delayed_work_wake_lock);
 
        return ret;
 }
@@ -2595,7 +2591,6 @@ 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);