diff options
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/main.c | 2 | ||||
-rw-r--r-- | kernel/power/power.h | 4 | ||||
-rw-r--r-- | kernel/power/user.c | 36 |
3 files changed, 40 insertions, 2 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index 9cb235cba4a9..ee371f50ccaa 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -103,7 +103,7 @@ static int suspend_prepare(suspend_state_t state) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | static int suspend_enter(suspend_state_t state) | 106 | int suspend_enter(suspend_state_t state) |
107 | { | 107 | { |
108 | int error = 0; | 108 | int error = 0; |
109 | unsigned long flags; | 109 | unsigned long flags; |
diff --git a/kernel/power/power.h b/kernel/power/power.h index 42c431c8bdde..f06f12f21767 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -77,7 +77,8 @@ int snapshot_image_loaded(struct snapshot_handle *handle); | |||
77 | #define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *) | 77 | #define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *) |
78 | #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) | 78 | #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) |
79 | #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) | 79 | #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) |
80 | #define SNAPSHOT_IOC_MAXNR 10 | 80 | #define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) |
81 | #define SNAPSHOT_IOC_MAXNR 11 | ||
81 | 82 | ||
82 | /** | 83 | /** |
83 | * The bitmap is used for tracing allocated swap pages | 84 | * The bitmap is used for tracing allocated swap pages |
@@ -112,3 +113,4 @@ extern int swsusp_resume(void); | |||
112 | extern int swsusp_read(void); | 113 | extern int swsusp_read(void); |
113 | extern int swsusp_write(void); | 114 | extern int swsusp_write(void); |
114 | extern void swsusp_close(void); | 115 | extern void swsusp_close(void); |
116 | extern int suspend_enter(suspend_state_t state); | ||
diff --git a/kernel/power/user.c b/kernel/power/user.c index bbd4842104aa..3f1539fbe48a 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -266,6 +266,42 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
266 | } | 266 | } |
267 | break; | 267 | break; |
268 | 268 | ||
269 | case SNAPSHOT_S2RAM: | ||
270 | if (!data->frozen) { | ||
271 | error = -EPERM; | ||
272 | break; | ||
273 | } | ||
274 | |||
275 | if (down_trylock(&pm_sem)) { | ||
276 | error = -EBUSY; | ||
277 | break; | ||
278 | } | ||
279 | |||
280 | if (pm_ops->prepare) { | ||
281 | error = pm_ops->prepare(PM_SUSPEND_MEM); | ||
282 | if (error) | ||
283 | goto OutS3; | ||
284 | } | ||
285 | |||
286 | /* Put devices to sleep */ | ||
287 | error = device_suspend(PMSG_SUSPEND); | ||
288 | if (error) { | ||
289 | printk(KERN_ERR "Failed to suspend some devices.\n"); | ||
290 | } else { | ||
291 | /* Enter S3, system is already frozen */ | ||
292 | suspend_enter(PM_SUSPEND_MEM); | ||
293 | |||
294 | /* Wake up devices */ | ||
295 | device_resume(); | ||
296 | } | ||
297 | |||
298 | if (pm_ops->finish) | ||
299 | pm_ops->finish(PM_SUSPEND_MEM); | ||
300 | |||
301 | OutS3: | ||
302 | up(&pm_sem); | ||
303 | break; | ||
304 | |||
269 | default: | 305 | default: |
270 | error = -ENOTTY; | 306 | error = -ENOTTY; |
271 | 307 | ||