diff options
author | Dave Jones <davej@redhat.com> | 2006-12-12 17:41:41 -0500 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2006-12-12 17:41:41 -0500 |
commit | c4366889dda8110247be59ca41fddb82951a8c26 (patch) | |
tree | 705c1a996bed8fd48ce94ff33ec9fd00f9b94875 /include/linux/freezer.h | |
parent | db2fb9db5735cc532fd4fc55e94b9a3c3750378e (diff) | |
parent | e1036502e5263851259d147771226161e5ccc85a (diff) |
Merge ../linus
Conflicts:
drivers/cpufreq/cpufreq.c
Diffstat (limited to 'include/linux/freezer.h')
-rw-r--r-- | include/linux/freezer.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h new file mode 100644 index 000000000000..393063096134 --- /dev/null +++ b/include/linux/freezer.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /* Freezer declarations */ | ||
2 | |||
3 | #include <linux/sched.h> | ||
4 | |||
5 | #ifdef CONFIG_PM | ||
6 | /* | ||
7 | * Check if a process has been frozen | ||
8 | */ | ||
9 | static inline int frozen(struct task_struct *p) | ||
10 | { | ||
11 | return p->flags & PF_FROZEN; | ||
12 | } | ||
13 | |||
14 | /* | ||
15 | * Check if there is a request to freeze a process | ||
16 | */ | ||
17 | static inline int freezing(struct task_struct *p) | ||
18 | { | ||
19 | return p->flags & PF_FREEZE; | ||
20 | } | ||
21 | |||
22 | /* | ||
23 | * Request that a process be frozen | ||
24 | * FIXME: SMP problem. We may not modify other process' flags! | ||
25 | */ | ||
26 | static inline void freeze(struct task_struct *p) | ||
27 | { | ||
28 | p->flags |= PF_FREEZE; | ||
29 | } | ||
30 | |||
31 | /* | ||
32 | * Sometimes we may need to cancel the previous 'freeze' request | ||
33 | */ | ||
34 | static inline void do_not_freeze(struct task_struct *p) | ||
35 | { | ||
36 | p->flags &= ~PF_FREEZE; | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Wake up a frozen process | ||
41 | */ | ||
42 | static inline int thaw_process(struct task_struct *p) | ||
43 | { | ||
44 | if (frozen(p)) { | ||
45 | p->flags &= ~PF_FROZEN; | ||
46 | wake_up_process(p); | ||
47 | return 1; | ||
48 | } | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | /* | ||
53 | * freezing is complete, mark process as frozen | ||
54 | */ | ||
55 | static inline void frozen_process(struct task_struct *p) | ||
56 | { | ||
57 | p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN; | ||
58 | } | ||
59 | |||
60 | extern void refrigerator(void); | ||
61 | extern int freeze_processes(void); | ||
62 | extern void thaw_processes(void); | ||
63 | |||
64 | static inline int try_to_freeze(void) | ||
65 | { | ||
66 | if (freezing(current)) { | ||
67 | refrigerator(); | ||
68 | return 1; | ||
69 | } else | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | extern void thaw_some_processes(int all); | ||
74 | |||
75 | #else | ||
76 | static inline int frozen(struct task_struct *p) { return 0; } | ||
77 | static inline int freezing(struct task_struct *p) { return 0; } | ||
78 | static inline void freeze(struct task_struct *p) { BUG(); } | ||
79 | static inline int thaw_process(struct task_struct *p) { return 1; } | ||
80 | static inline void frozen_process(struct task_struct *p) { BUG(); } | ||
81 | |||
82 | static inline void refrigerator(void) {} | ||
83 | static inline int freeze_processes(void) { BUG(); return 0; } | ||
84 | static inline void thaw_processes(void) {} | ||
85 | |||
86 | static inline int try_to_freeze(void) { return 0; } | ||
87 | |||
88 | |||
89 | #endif | ||