misc: nct1008: change overheat enable message
[linux-3.10.git] / drivers / base / syscore.c
index 90af294..64465ed 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/syscore_ops.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
+#include <linux/interrupt.h>
 
 static LIST_HEAD(syscore_ops_list);
 static DEFINE_MUTEX(syscore_ops_lock);
@@ -48,6 +49,13 @@ int syscore_suspend(void)
        struct syscore_ops *ops;
        int ret = 0;
 
+       pr_debug("Checking wakeup interrupts\n");
+
+       /* Return error code if there are any wakeup interrupts pending. */
+       ret = check_wakeup_irqs();
+       if (ret)
+               return ret;
+
        WARN_ONCE(!irqs_disabled(),
                "Interrupts enabled before system core suspend.\n");
 
@@ -73,6 +81,7 @@ int syscore_suspend(void)
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(syscore_suspend);
 
 /**
  * syscore_resume - Execute all the registered system core resume callbacks.
@@ -88,13 +97,91 @@ void syscore_resume(void)
 
        list_for_each_entry(ops, &syscore_ops_list, node)
                if (ops->resume) {
-                       if (initcall_debug)
-                               pr_info("PM: Calling %pF\n", ops->resume);
                        ops->resume();
                        WARN_ONCE(!irqs_disabled(),
                                "Interrupts enabled after %pF\n", ops->resume);
                }
+       if (initcall_debug) {
+               list_for_each_entry(ops, &syscore_ops_list, node)
+                       if (ops->resume) {
+                               pr_info("PM: Called %pF\n", ops->resume);
+                       }
+       }
+}
+EXPORT_SYMBOL_GPL(syscore_resume);
+
+/**
+ * syscore_save - Execute all the registered system core save callbacks.
+ *
+ * This function is executed when going into deep idle state to save system
+ * context.
+ */
+int syscore_save(void)
+{
+       struct syscore_ops *ops;
+       int ret = 0;
+
+       pr_debug("Checking wakeup interrupts\n");
+
+       /* Return error code if there are any wakeup interrupts pending. */
+       ret = check_wakeup_irqs();
+       if (ret)
+               return ret;
+
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled before system core suspend.\n");
+
+       list_for_each_entry_reverse(ops, &syscore_ops_list, node)
+               if (ops->save) {
+                       if (initcall_debug)
+                               pr_info("PM: Calling %pF\n", ops->save);
+                       ret = ops->save();
+                       if (ret)
+                               goto err_out;
+                       WARN_ONCE(!irqs_disabled(),
+                               "Interrupts enabled after %pF\n", ops->save);
+               }
+
+       return 0;
+
+ err_out:
+       pr_err("PM: System core save callback %pF failed.\n", ops->save);
+
+       list_for_each_entry_continue(ops, &syscore_ops_list, node)
+               if (ops->restore)
+                       ops->restore();
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(syscore_save);
+
+/**
+ * syscore_restore - Execute all the registered system core restore callbacks.
+ *
+ * This function is executed after resuming from deep idle state to restore
+ * system context.
+ */
+void syscore_restore(void)
+{
+       struct syscore_ops *ops;
+
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled before system core resume.\n");
+
+       list_for_each_entry(ops, &syscore_ops_list, node)
+               if (ops->restore) {
+                       ops->restore();
+                       WARN_ONCE(!irqs_disabled(),
+                               "Interrupts enabled after %pF\n", ops->restore);
+               }
+       if (initcall_debug) {
+               list_for_each_entry(ops, &syscore_ops_list, node)
+                       if (ops->restore) {
+                               pr_info("PM: Called %pF\n", ops->restore);
+                       }
+       }
 }
+EXPORT_SYMBOL_GPL(syscore_restore);
 #endif /* CONFIG_PM_SLEEP */
 
 /**