diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-07-19 04:47:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:42 -0400 |
commit | 6c961dfb7c903cfd1cd71b506863894038fd704f (patch) | |
tree | 32890d6ef2cf735243d804778a5b62951aed4ef5 /kernel/power/user.c | |
parent | ccd4b65aef4be2278543fde5b999e55a4d694fd8 (diff) |
PM: Reduce code duplication between main.c and user.c
The SNAPSHOT_S2RAM ioctl code is outdated and it should not duplicate the
suspend code in kernel/power/main.c. Fix that.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Cc: Nigel Cunningham <nigel@nigel.suspend2.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r-- | kernel/power/user.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c index 7f19afe01b48..bd0723a7df3f 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -255,47 +255,19 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, | |||
255 | break; | 255 | break; |
256 | 256 | ||
257 | case SNAPSHOT_S2RAM: | 257 | case SNAPSHOT_S2RAM: |
258 | if (!pm_ops) { | ||
259 | error = -ENOSYS; | ||
260 | break; | ||
261 | } | ||
262 | |||
263 | if (!data->frozen) { | 258 | if (!data->frozen) { |
264 | error = -EPERM; | 259 | error = -EPERM; |
265 | break; | 260 | break; |
266 | } | 261 | } |
267 | |||
268 | if (!mutex_trylock(&pm_mutex)) { | 262 | if (!mutex_trylock(&pm_mutex)) { |
269 | error = -EBUSY; | 263 | error = -EBUSY; |
270 | break; | 264 | break; |
271 | } | 265 | } |
272 | 266 | /* | |
273 | if (pm_ops->prepare) { | 267 | * Tasks are frozen and the notifiers have been called with |
274 | error = pm_ops->prepare(PM_SUSPEND_MEM); | 268 | * PM_HIBERNATION_PREPARE |
275 | if (error) | 269 | */ |
276 | goto OutS3; | 270 | error = suspend_devices_and_enter(PM_SUSPEND_MEM); |
277 | } | ||
278 | |||
279 | /* Put devices to sleep */ | ||
280 | suspend_console(); | ||
281 | error = device_suspend(PMSG_SUSPEND); | ||
282 | if (error) { | ||
283 | printk(KERN_ERR "Failed to suspend some devices.\n"); | ||
284 | } else { | ||
285 | error = disable_nonboot_cpus(); | ||
286 | if (!error) { | ||
287 | /* Enter S3, system is already frozen */ | ||
288 | suspend_enter(PM_SUSPEND_MEM); | ||
289 | enable_nonboot_cpus(); | ||
290 | } | ||
291 | /* Wake up devices */ | ||
292 | device_resume(); | ||
293 | } | ||
294 | resume_console(); | ||
295 | if (pm_ops->finish) | ||
296 | pm_ops->finish(PM_SUSPEND_MEM); | ||
297 | |||
298 | OutS3: | ||
299 | mutex_unlock(&pm_mutex); | 271 | mutex_unlock(&pm_mutex); |
300 | break; | 272 | break; |
301 | 273 | ||