summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2005-01-03 05:01:05 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-03 05:01:05 -0800
commit54820fb262a0dafad2e11aa552527d1b36091bf9 (patch)
treecb3d7516019d967a192120812c292c68f3e76c6d /include
parenteaefadeb9eda1611f34b186fcea3465387032ebc (diff)
[PATCH] swsusp: try_to_freeze to make freezing hooks nicer
This moves refrigerator changes to sched.h, so that every file user of refrigerator does not have to include suspend.h, and makes refrigerator support easier by introducing try_to_freeze. Adapted from patch by Nigel Cunningham Signed-off-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sched.h28
-rw-r--r--include/linux/suspend.h20
2 files changed, 33 insertions, 15 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 440393fcd5c7..9491a26f0f93 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1124,6 +1124,34 @@ extern void normalize_rt_tasks(void);
#endif
+/* try_to_freeze
+ *
+ * Checks whether we need to enter the refrigerator
+ * and returns 1 if we did so.
+ */
+#ifdef CONFIG_PM
+extern void refrigerator(unsigned long);
+extern int freeze_processes(void);
+extern void thaw_processes(void);
+
+static inline int try_to_freeze(unsigned long refrigerator_flags)
+{
+ if (unlikely(current->flags & PF_FREEZE)) {
+ refrigerator(refrigerator_flags);
+ return 1;
+ } else
+ return 0;
+}
+#else
+static inline void refrigerator(unsigned long flag) {}
+static inline int freeze_processes(void) { BUG(); }
+static inline void thaw_processes(void) {}
+
+static inline int try_to_freeze(unsigned long refrigerator_flags)
+{
+ return 0;
+}
+#endif /* CONFIG_PM */
#endif /* __KERNEL__ */
#endif
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 18f0145fcbbc..4e4c2962809f 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -36,26 +36,16 @@ extern void mark_free_pages(struct zone *zone);
/* kernel/power/swsusp.c */
extern int software_suspend(void);
-#else /* CONFIG_SOFTWARE_SUSPEND */
+extern int pm_prepare_console(void);
+extern void pm_restore_console(void);
+
+#else
static inline int software_suspend(void)
{
printk("Warning: fake suspend called\n");
return -EPERM;
}
-#endif /* CONFIG_SOFTWARE_SUSPEND */
-
-
-#ifdef CONFIG_PM
-extern void refrigerator(unsigned long);
-extern int freeze_processes(void);
-extern void thaw_processes(void);
-
-extern int pm_prepare_console(void);
-extern void pm_restore_console(void);
-
-#else
-static inline void refrigerator(unsigned long flag) {}
-#endif /* CONFIG_PM */
+#endif
#ifdef CONFIG_SMP
extern void disable_nonboot_cpus(void);