PM: Separate hibernation code from suspend code

[ With Johannes Berg <johannes@sipsolutions.net> ]

Separate the hibernation (aka suspend to disk code) from the other suspend
code.  In particular:

 * Remove the definitions related to hibernation from include/linux/pm.h
 * Introduce struct hibernation_ops and a new hibernate() function to hibernate
   the system, defined in include/linux/suspend.h
 * Separate suspend code in kernel/power/main.c from hibernation-related code
   in kernel/power/disk.c and kernel/power/user.c (with the help of
   hibernation_ops)
 * Switch ACPI (the only user of pm_ops.pm_disk_mode) to hibernation_ops

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Cc: 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>
This commit is contained in:
Rafael J. Wysocki 2007-05-09 02:33:18 -07:00 committed by Linus Torvalds
parent d60846c4d1
commit a3d25c275d
11 changed files with 227 additions and 186 deletions

View file

@ -130,16 +130,16 @@ static inline int platform_prepare(void)
{
int error = 0;
if (pm_ops && pm_ops->prepare)
error = pm_ops->prepare(PM_SUSPEND_DISK);
if (hibernation_ops)
error = hibernation_ops->prepare();
return error;
}
static inline void platform_finish(void)
{
if (pm_ops && pm_ops->finish)
pm_ops->finish(PM_SUSPEND_DISK);
if (hibernation_ops)
hibernation_ops->finish();
}
static inline int snapshot_suspend(int platform_suspend)
@ -384,7 +384,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
switch (arg) {
case PMOPS_PREPARE:
if (pm_ops && pm_ops->enter) {
if (hibernation_ops) {
data->platform_suspend = 1;
error = 0;
} else {
@ -395,8 +395,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
case PMOPS_ENTER:
if (data->platform_suspend) {
kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
error = pm_ops->enter(PM_SUSPEND_DISK);
error = 0;
error = hibernation_ops->enter();
}
break;