diff options
Diffstat (limited to 'kernel/power/power.h')
-rw-r--r-- | kernel/power/power.h | 90 |
1 files changed, 53 insertions, 37 deletions
diff --git a/kernel/power/power.h b/kernel/power/power.h index 2093c3a9a994..700f44ec8406 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -1,5 +1,7 @@ | |||
1 | #include <linux/suspend.h> | 1 | #include <linux/suspend.h> |
2 | #include <linux/suspend_ioctls.h> | ||
2 | #include <linux/utsname.h> | 3 | #include <linux/utsname.h> |
4 | #include <linux/freezer.h> | ||
3 | 5 | ||
4 | struct swsusp_info { | 6 | struct swsusp_info { |
5 | struct new_utsname uts; | 7 | struct new_utsname uts; |
@@ -128,42 +130,12 @@ struct snapshot_handle { | |||
128 | #define data_of(handle) ((handle).buffer + (handle).buf_offset) | 130 | #define data_of(handle) ((handle).buffer + (handle).buf_offset) |
129 | 131 | ||
130 | extern unsigned int snapshot_additional_pages(struct zone *zone); | 132 | extern unsigned int snapshot_additional_pages(struct zone *zone); |
133 | extern unsigned long snapshot_get_image_size(void); | ||
131 | extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); | 134 | extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); |
132 | extern int snapshot_write_next(struct snapshot_handle *handle, size_t count); | 135 | extern int snapshot_write_next(struct snapshot_handle *handle, size_t count); |
133 | extern void snapshot_write_finalize(struct snapshot_handle *handle); | 136 | extern void snapshot_write_finalize(struct snapshot_handle *handle); |
134 | extern int snapshot_image_loaded(struct snapshot_handle *handle); | 137 | extern int snapshot_image_loaded(struct snapshot_handle *handle); |
135 | 138 | ||
136 | /* | ||
137 | * This structure is used to pass the values needed for the identification | ||
138 | * of the resume swap area from a user space to the kernel via the | ||
139 | * SNAPSHOT_SET_SWAP_AREA ioctl | ||
140 | */ | ||
141 | struct resume_swap_area { | ||
142 | loff_t offset; | ||
143 | u_int32_t dev; | ||
144 | } __attribute__((packed)); | ||
145 | |||
146 | #define SNAPSHOT_IOC_MAGIC '3' | ||
147 | #define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1) | ||
148 | #define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2) | ||
149 | #define SNAPSHOT_ATOMIC_SNAPSHOT _IOW(SNAPSHOT_IOC_MAGIC, 3, void *) | ||
150 | #define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4) | ||
151 | #define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5) | ||
152 | #define SNAPSHOT_SET_IMAGE_SIZE _IOW(SNAPSHOT_IOC_MAGIC, 6, unsigned long) | ||
153 | #define SNAPSHOT_AVAIL_SWAP _IOR(SNAPSHOT_IOC_MAGIC, 7, void *) | ||
154 | #define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *) | ||
155 | #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) | ||
156 | #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) | ||
157 | #define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) | ||
158 | #define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int) | ||
159 | #define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \ | ||
160 | struct resume_swap_area) | ||
161 | #define SNAPSHOT_IOC_MAXNR 13 | ||
162 | |||
163 | #define PMOPS_PREPARE 1 | ||
164 | #define PMOPS_ENTER 2 | ||
165 | #define PMOPS_FINISH 3 | ||
166 | |||
167 | /* If unset, the snapshot device cannot be open. */ | 139 | /* If unset, the snapshot device cannot be open. */ |
168 | extern atomic_t snapshot_device_available; | 140 | extern atomic_t snapshot_device_available; |
169 | 141 | ||
@@ -181,7 +153,6 @@ extern int swsusp_swap_in_use(void); | |||
181 | extern int swsusp_check(void); | 153 | extern int swsusp_check(void); |
182 | extern int swsusp_shrink_memory(void); | 154 | extern int swsusp_shrink_memory(void); |
183 | extern void swsusp_free(void); | 155 | extern void swsusp_free(void); |
184 | extern int swsusp_resume(void); | ||
185 | extern int swsusp_read(unsigned int *flags_p); | 156 | extern int swsusp_read(unsigned int *flags_p); |
186 | extern int swsusp_write(unsigned int flags); | 157 | extern int swsusp_write(unsigned int flags); |
187 | extern void swsusp_close(void); | 158 | extern void swsusp_close(void); |
@@ -201,11 +172,56 @@ static inline int suspend_devices_and_enter(suspend_state_t state) | |||
201 | } | 172 | } |
202 | #endif /* !CONFIG_SUSPEND */ | 173 | #endif /* !CONFIG_SUSPEND */ |
203 | 174 | ||
204 | /* kernel/power/common.c */ | 175 | #ifdef CONFIG_PM_SLEEP |
205 | extern struct blocking_notifier_head pm_chain_head; | 176 | /* kernel/power/main.c */ |
177 | extern int pm_notifier_call_chain(unsigned long val); | ||
178 | #endif | ||
179 | |||
180 | #ifdef CONFIG_HIGHMEM | ||
181 | unsigned int count_highmem_pages(void); | ||
182 | int restore_highmem(void); | ||
183 | #else | ||
184 | static inline unsigned int count_highmem_pages(void) { return 0; } | ||
185 | static inline int restore_highmem(void) { return 0; } | ||
186 | #endif | ||
187 | |||
188 | /* | ||
189 | * Suspend test levels | ||
190 | */ | ||
191 | enum { | ||
192 | /* keep first */ | ||
193 | TEST_NONE, | ||
194 | TEST_CORE, | ||
195 | TEST_CPUS, | ||
196 | TEST_PLATFORM, | ||
197 | TEST_DEVICES, | ||
198 | TEST_FREEZER, | ||
199 | /* keep last */ | ||
200 | __TEST_AFTER_LAST | ||
201 | }; | ||
202 | |||
203 | #define TEST_FIRST TEST_NONE | ||
204 | #define TEST_MAX (__TEST_AFTER_LAST - 1) | ||
205 | |||
206 | extern int pm_test_level; | ||
207 | |||
208 | #ifdef CONFIG_SUSPEND_FREEZER | ||
209 | static inline int suspend_freeze_processes(void) | ||
210 | { | ||
211 | return freeze_processes(); | ||
212 | } | ||
206 | 213 | ||
207 | static inline int pm_notifier_call_chain(unsigned long val) | 214 | static inline void suspend_thaw_processes(void) |
208 | { | 215 | { |
209 | return (blocking_notifier_call_chain(&pm_chain_head, val, NULL) | 216 | thaw_processes(); |
210 | == NOTIFY_BAD) ? -EINVAL : 0; | ||
211 | } | 217 | } |
218 | #else | ||
219 | static inline int suspend_freeze_processes(void) | ||
220 | { | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static inline void suspend_thaw_processes(void) | ||
225 | { | ||
226 | } | ||
227 | #endif | ||