diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c index 2583856fab3..0db39b85129 100644 --- a/kernel/power/wakelock.c +++ b/kernel/power/wakelock.c @@ -265,6 +265,9 @@ long has_wake_lock(int type) return ret; } +static bool is_suspend_sys_sync_waiting; +static void suspend_sys_sync_handler(unsigned long); +static DEFINE_TIMER(suspend_sys_sync_timer, suspend_sys_sync_handler, 0, 0); static void suspend_sys_sync(struct work_struct *work) { if (debug_mask & DEBUG_SUSPEND) @@ -277,6 +280,10 @@ static void suspend_sys_sync(struct work_struct *work) spin_lock(&suspend_sys_sync_lock); suspend_sys_sync_count--; + if (is_suspend_sys_sync_waiting && (suspend_sys_sync_count == 0)) { + complete(&suspend_sys_sync_comp); + del_timer(&suspend_sys_sync_timer); + } spin_unlock(&suspend_sys_sync_lock); } static DECLARE_WORK(suspend_sys_sync_work, suspend_sys_sync); @@ -293,8 +300,6 @@ void suspend_sys_sync_queue(void) } static bool suspend_sys_sync_abort; -static void suspend_sys_sync_handler(unsigned long); -static DEFINE_TIMER(suspend_sys_sync_timer, suspend_sys_sync_handler, 0, 0); /* value should be less then half of input event wake lock timeout value * which is currently set to 5*HZ (see drivers/input/evdev.c) */ @@ -319,7 +324,9 @@ int suspend_sys_sync_wait(void) if (suspend_sys_sync_count != 0) { mod_timer(&suspend_sys_sync_timer, jiffies + SUSPEND_SYS_SYNC_TIMEOUT); + is_suspend_sys_sync_waiting = true; wait_for_completion(&suspend_sys_sync_comp); + is_suspend_sys_sync_waiting = false; } if (suspend_sys_sync_abort) { pr_info("suspend aborted....while waiting for sys_sync\n");