Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7004
b: refs/heads/master
c: 99dc7d6
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Machek authored and Linus Torvalds committed Sep 5, 2005
1 parent 98196e3 commit b965361
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dd5d666b7995e542b7f81a4bb1c7ad634f4f6c51
refs/heads/master: 99dc7d63e0dcb457580241055b2a39d011309db8
45 changes: 16 additions & 29 deletions trunk/kernel/power/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,12 @@ static inline void platform_finish(void)
}
}

static void finish(void)
{
device_resume();
platform_finish();
thaw_processes();
enable_nonboot_cpus();
pm_restore_console();
}


static int prepare_processes(void)
{
int error;

pm_prepare_console();

sys_sync();

disable_nonboot_cpus();

if (freeze_processes()) {
Expand Down Expand Up @@ -162,15 +150,6 @@ static void unprepare_processes(void)
pm_restore_console();
}

static int prepare_devices(void)
{
int error;

if ((error = device_suspend(PMSG_FREEZE)))
printk("Some devices failed to suspend\n");
return error;
}

/**
* pm_suspend_disk - The granpappy of power management.
*
Expand All @@ -187,17 +166,14 @@ int pm_suspend_disk(void)
error = prepare_processes();
if (error)
return error;
error = prepare_devices();

error = device_suspend(PMSG_FREEZE);
if (error) {
printk("Some devices failed to suspend\n");
unprepare_processes();
return error;
}

pr_debug("PM: Attempting to suspend to disk.\n");
if (pm_disk_mode == PM_DISK_FIRMWARE)
return pm_ops->enter(PM_SUSPEND_DISK);

pr_debug("PM: snapshotting memory.\n");
in_suspend = 1;
if ((error = swsusp_suspend()))
Expand All @@ -208,11 +184,20 @@ int pm_suspend_disk(void)
error = swsusp_write();
if (!error)
power_down(pm_disk_mode);
else {
/* swsusp_write can not fail in device_resume,
no need to do second device_resume */
swsusp_free();
unprepare_processes();
return error;
}
} else
pr_debug("PM: Image restored successfully.\n");

swsusp_free();
Done:
finish();
device_resume();
unprepare_processes();
return error;
}

Expand Down Expand Up @@ -274,15 +259,17 @@ static int software_resume(void)

pr_debug("PM: Preparing devices for restore.\n");

if ((error = prepare_devices()))
if ((error = device_suspend(PMSG_FREEZE))) {
printk("Some devices failed to suspend\n");
goto Free;
}

mb();

pr_debug("PM: Restoring saved image.\n");
swsusp_resume();
pr_debug("PM: Restore failed, recovering.n");
finish();
device_resume();
Free:
swsusp_free();
Cleanup:
Expand Down
12 changes: 6 additions & 6 deletions trunk/kernel/power/swsusp.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ static int write_pagedir(void)
* write_suspend_image - Write entire image and metadata.
*
*/

static int write_suspend_image(void)
{
int error;
Expand Down Expand Up @@ -1021,20 +1020,21 @@ int swsusp_suspend(void)
* at resume time, and evil weirdness ensues.
*/
if ((error = device_power_down(PMSG_FREEZE))) {
printk(KERN_ERR "Some devices failed to power down, aborting suspend\n");
local_irq_enable();
return error;
}

if ((error = swsusp_swap_check())) {
printk(KERN_ERR "swsusp: FATAL: cannot find swap device, try "
"swapon -a!\n");
printk(KERN_ERR "swsusp: cannot find swap device, try swapon -a.\n");
device_power_up();
local_irq_enable();
return error;
}

save_processor_state();
if ((error = swsusp_arch_suspend()))
printk("Error %d suspending\n", error);
printk(KERN_ERR "Error %d suspending\n", error);
/* Restore control flow magically appears here */
restore_processor_state();
BUG_ON (nr_copy_pages_check != nr_copy_pages);
Expand Down Expand Up @@ -1314,7 +1314,8 @@ static const char * sanity_check(void)
if (strcmp(swsusp_info.uts.machine,system_utsname.machine))
return "machine";
#if 0
if(swsusp_info.cpus != num_online_cpus())
/* We can't use number of online CPUs when we use hotplug to remove them ;-))) */
if (swsusp_info.cpus != num_possible_cpus())
return "number of cpus";
#endif
return NULL;
Expand Down Expand Up @@ -1355,7 +1356,6 @@ static int check_sig(void)
*/
error = bio_write_page(0, &swsusp_header);
} else {
printk(KERN_ERR "swsusp: Suspend partition has wrong signature?\n");
return -EINVAL;
}
if (!error)
Expand Down

0 comments on commit b965361

Please sign in to comment.