Commit c2cd403c authored by Patrick Mochel's avatar Patrick Mochel

[Power Mgmt] Merge pmdisk and swsusp write wrappers.

- Merge suspend_save_image() from both into one.
- Rename to swsusp_write(). 
- Remove pmdisk_write().
- Fixup call in kernel/power/disk.c and software_suspend().
- Mark lock_swapdevices() static again.
parent a5b568fe
...@@ -24,7 +24,7 @@ extern u32 pm_disk_mode; ...@@ -24,7 +24,7 @@ extern u32 pm_disk_mode;
extern struct pm_ops * pm_ops; extern struct pm_ops * pm_ops;
extern int swsusp_suspend(void); extern int swsusp_suspend(void);
extern int pmdisk_write(void); extern int swsusp_write(void);
extern int swsusp_read(void); extern int swsusp_read(void);
extern int swsusp_resume(void); extern int swsusp_resume(void);
extern int pmdisk_free(void); extern int pmdisk_free(void);
...@@ -173,7 +173,7 @@ int pm_suspend_disk(void) ...@@ -173,7 +173,7 @@ int pm_suspend_disk(void)
mb(); mb();
barrier(); barrier();
error = pmdisk_write(); error = swsusp_write();
if (!error) { if (!error) {
error = power_down(pm_disk_mode); error = power_down(pm_disk_mode);
pr_debug("PM: Power down failed.\n"); pr_debug("PM: Power down failed.\n");
......
...@@ -42,49 +42,6 @@ extern suspend_pagedir_t *pagedir_save; ...@@ -42,49 +42,6 @@ extern suspend_pagedir_t *pagedir_save;
*/ */
extern void swsusp_swap_lock(void);
/**
* suspend_save_image - Prepare and write saved image to swap.
*
* IRQs are re-enabled here so we can resume devices and safely write
* to the swap devices. We disable them again before we leave.
*
* The second swsusp_swap_lock() will unlock ignored swap devices since
* writing is finished.
* It is important _NOT_ to umount filesystems at this point. We want
* them synced (in case something goes wrong) but we DO not want to mark
* filesystem clean: it is not. (And it does not matter, if we resume
* correctly, we'll mark system clean, anyway.)
*/
static int suspend_save_image(void)
{
extern int write_suspend_image(void);
int error;
device_resume();
swsusp_swap_lock();
error = write_suspend_image();
swsusp_swap_lock();
return error;
}
/**
* pmdisk_write - Write saved memory image to swap.
*
* pmdisk_arch_suspend(0) returns after system is resumed.
*
* pmdisk_arch_suspend() copies all "used" memory to "free" memory,
* then unsuspends all device drivers, and writes memory to disk
* using normal kernel mechanism.
*/
int pmdisk_write(void)
{
return suspend_save_image();
}
/** /**
* pmdisk_free - Free memory allocated to hold snapshot. * pmdisk_free - Free memory allocated to hold snapshot.
*/ */
......
...@@ -246,7 +246,7 @@ int swsusp_swap_check(void) /* This is called before saving image */ ...@@ -246,7 +246,7 @@ int swsusp_swap_check(void) /* This is called before saving image */
* we make the device unusable. A new call to * we make the device unusable. A new call to
* lock_swapdevices can unlock the devices. * lock_swapdevices can unlock the devices.
*/ */
void swsusp_swap_lock(void) static void lock_swapdevices(void)
{ {
int i; int i;
...@@ -439,7 +439,7 @@ static int write_pagedir(void) ...@@ -439,7 +439,7 @@ static int write_pagedir(void)
* *
*/ */
int write_suspend_image(void) static int write_suspend_image(void)
{ {
int error; int error;
...@@ -862,20 +862,22 @@ int suspend_prepare_image(void) ...@@ -862,20 +862,22 @@ int suspend_prepare_image(void)
return 0; return 0;
} }
static void suspend_save_image(void)
{
device_resume();
swsusp_swap_lock(); /* It is important _NOT_ to umount filesystems at this point. We want
write_suspend_image();
/* This will unlock ignored swap devices since writing is finished */
swsusp_swap_lock();
/* It is important _NOT_ to umount filesystems at this point. We want
* them synced (in case something goes wrong) but we DO not want to mark * them synced (in case something goes wrong) but we DO not want to mark
* filesystem clean: it is not. (And it does not matter, if we resume * filesystem clean: it is not. (And it does not matter, if we resume
* correctly, we'll mark system clean, anyway.) * correctly, we'll mark system clean, anyway.)
*/ */
int swsusp_write(void)
{
int error;
device_resume();
lock_swapdevices();
error = write_suspend_image();
/* This will unlock ignored swap devices since writing is finished */
lock_swapdevices();
return error;
} }
static void suspend_power_down(void) static void suspend_power_down(void)
...@@ -1011,7 +1013,7 @@ int software_suspend(void) ...@@ -1011,7 +1013,7 @@ int software_suspend(void)
res = swsusp_save(); res = swsusp_save();
if (!res && in_suspend) { if (!res && in_suspend) {
suspend_save_image(); swsusp_write();
suspend_power_down(); suspend_power_down();
} }
in_suspend = 0; in_suspend = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment