Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[muen/linux.git] / kernel / power / suspend.c
index be3d0d4776618e0677b2c3548c6f01681404925a..0bd595a0b6103c56439871b765ef0d4fb5ac672b 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/export.h>
 #include <linux/suspend.h>
 #include <linux/syscore_ops.h>
+#include <linux/swait.h>
 #include <linux/ftrace.h>
 #include <trace/events/power.h>
 #include <linux/compiler.h>
@@ -57,10 +58,10 @@ EXPORT_SYMBOL_GPL(pm_suspend_global_flags);
 
 static const struct platform_suspend_ops *suspend_ops;
 static const struct platform_s2idle_ops *s2idle_ops;
-static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head);
+static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
 
 enum s2idle_states __read_mostly s2idle_state;
-static DEFINE_SPINLOCK(s2idle_lock);
+static DEFINE_RAW_SPINLOCK(s2idle_lock);
 
 bool pm_suspend_via_s2idle(void)
 {
@@ -84,12 +85,12 @@ static void s2idle_enter(void)
 {
        trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true);
 
-       spin_lock_irq(&s2idle_lock);
+       raw_spin_lock_irq(&s2idle_lock);
        if (pm_wakeup_pending())
                goto out;
 
        s2idle_state = S2IDLE_STATE_ENTER;
-       spin_unlock_irq(&s2idle_lock);
+       raw_spin_unlock_irq(&s2idle_lock);
 
        get_online_cpus();
        cpuidle_resume();
@@ -97,17 +98,17 @@ static void s2idle_enter(void)
        /* Push all the CPUs into the idle loop. */
        wake_up_all_idle_cpus();
        /* Make the current CPU wait so it can enter the idle loop too. */
-       wait_event(s2idle_wait_head,
-                  s2idle_state == S2IDLE_STATE_WAKE);
+       swait_event_exclusive(s2idle_wait_head,
+                   s2idle_state == S2IDLE_STATE_WAKE);
 
        cpuidle_pause();
        put_online_cpus();
 
-       spin_lock_irq(&s2idle_lock);
+       raw_spin_lock_irq(&s2idle_lock);
 
  out:
        s2idle_state = S2IDLE_STATE_NONE;
-       spin_unlock_irq(&s2idle_lock);
+       raw_spin_unlock_irq(&s2idle_lock);
 
        trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, false);
 }
@@ -162,12 +163,12 @@ void s2idle_wake(void)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&s2idle_lock, flags);
+       raw_spin_lock_irqsave(&s2idle_lock, flags);
        if (s2idle_state > S2IDLE_STATE_NONE) {
                s2idle_state = S2IDLE_STATE_WAKE;
-               wake_up(&s2idle_wait_head);
+               swake_up_one(&s2idle_wait_head);
        }
-       spin_unlock_irqrestore(&s2idle_lock, flags);
+       raw_spin_unlock_irqrestore(&s2idle_lock, flags);
 }
 EXPORT_SYMBOL_GPL(s2idle_wake);
 
@@ -434,6 +435,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
        arch_suspend_disable_irqs();
        BUG_ON(!irqs_disabled());
 
+       system_state = SYSTEM_SUSPEND;
+
        error = syscore_suspend();
        if (!error) {
                *wakeup = pm_wakeup_pending();
@@ -449,6 +452,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
                syscore_resume();
        }
 
+       system_state = SYSTEM_RUNNING;
+
        arch_suspend_enable_irqs();
        BUG_ON(irqs_disabled());
 
@@ -557,7 +562,7 @@ static int enter_state(suspend_state_t state)
        } else if (!valid_state(state)) {
                return -EINVAL;
        }
-       if (!mutex_trylock(&pm_mutex))
+       if (!mutex_trylock(&system_transition_mutex))
                return -EBUSY;
 
        if (state == PM_SUSPEND_TO_IDLE)
@@ -591,7 +596,7 @@ static int enter_state(suspend_state_t state)
        pm_pr_dbg("Finishing wakeup.\n");
        suspend_finish();
  Unlock:
-       mutex_unlock(&pm_mutex);
+       mutex_unlock(&system_transition_mutex);
        return error;
 }