diff options
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r-- | kernel/power/user.c | 36 |
1 files changed, 36 insertions, 0 deletions
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 | ||