Commit 97c7801c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds

[PATCH] swsusp: Use suspend_console

Add suspend_console() and resume_console() to the suspend-to-disk code paths
so that the users of netconsole can use swsusp with it.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dea20a3f
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/console.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include "power.h" #include "power.h"
...@@ -119,8 +120,10 @@ int pm_suspend_disk(void) ...@@ -119,8 +120,10 @@ int pm_suspend_disk(void)
if (error) if (error)
return error; return error;
suspend_console();
error = device_suspend(PMSG_FREEZE); error = device_suspend(PMSG_FREEZE);
if (error) { if (error) {
resume_console();
printk("Some devices failed to suspend\n"); printk("Some devices failed to suspend\n");
unprepare_processes(); unprepare_processes();
return error; return error;
...@@ -133,6 +136,7 @@ int pm_suspend_disk(void) ...@@ -133,6 +136,7 @@ int pm_suspend_disk(void)
if (in_suspend) { if (in_suspend) {
device_resume(); device_resume();
resume_console();
pr_debug("PM: writing image.\n"); pr_debug("PM: writing image.\n");
error = swsusp_write(); error = swsusp_write();
if (!error) if (!error)
...@@ -148,6 +152,7 @@ int pm_suspend_disk(void) ...@@ -148,6 +152,7 @@ int pm_suspend_disk(void)
swsusp_free(); swsusp_free();
Done: Done:
device_resume(); device_resume();
resume_console();
unprepare_processes(); unprepare_processes();
return error; return error;
} }
...@@ -212,7 +217,9 @@ static int software_resume(void) ...@@ -212,7 +217,9 @@ static int software_resume(void)
pr_debug("PM: Preparing devices for restore.\n"); pr_debug("PM: Preparing devices for restore.\n");
suspend_console();
if ((error = device_suspend(PMSG_PRETHAW))) { if ((error = device_suspend(PMSG_PRETHAW))) {
resume_console();
printk("Some devices failed to suspend\n"); printk("Some devices failed to suspend\n");
swsusp_free(); swsusp_free();
goto Thaw; goto Thaw;
...@@ -224,6 +231,7 @@ static int software_resume(void) ...@@ -224,6 +231,7 @@ static int software_resume(void)
swsusp_resume(); swsusp_resume();
pr_debug("PM: Restore failed, recovering.n"); pr_debug("PM: Restore failed, recovering.n");
device_resume(); device_resume();
resume_console();
Thaw: Thaw:
unprepare_processes(); unprepare_processes();
Done: Done:
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/swapops.h> #include <linux/swapops.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/console.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -173,12 +174,14 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -173,12 +174,14 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
/* Free memory before shutting down devices. */ /* Free memory before shutting down devices. */
error = swsusp_shrink_memory(); error = swsusp_shrink_memory();
if (!error) { if (!error) {
suspend_console();
error = device_suspend(PMSG_FREEZE); error = device_suspend(PMSG_FREEZE);
if (!error) { if (!error) {
in_suspend = 1; in_suspend = 1;
error = swsusp_suspend(); error = swsusp_suspend();
device_resume(); device_resume();
} }
resume_console();
} }
up(&pm_sem); up(&pm_sem);
if (!error) if (!error)
...@@ -196,11 +199,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -196,11 +199,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
snapshot_free_unused_memory(&data->handle); snapshot_free_unused_memory(&data->handle);
down(&pm_sem); down(&pm_sem);
pm_prepare_console(); pm_prepare_console();
suspend_console();
error = device_suspend(PMSG_PRETHAW); error = device_suspend(PMSG_PRETHAW);
if (!error) { if (!error) {
error = swsusp_resume(); error = swsusp_resume();
device_resume(); device_resume();
} }
resume_console();
pm_restore_console(); pm_restore_console();
up(&pm_sem); up(&pm_sem);
break; break;
...@@ -289,6 +294,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -289,6 +294,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
} }
/* Put devices to sleep */ /* Put devices to sleep */
suspend_console();
error = device_suspend(PMSG_SUSPEND); error = device_suspend(PMSG_SUSPEND);
if (error) { if (error) {
printk(KERN_ERR "Failed to suspend some devices.\n"); printk(KERN_ERR "Failed to suspend some devices.\n");
...@@ -299,7 +305,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -299,7 +305,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
/* Wake up devices */ /* Wake up devices */
device_resume(); device_resume();
} }
resume_console();
if (pm_ops->finish) if (pm_ops->finish)
pm_ops->finish(PM_SUSPEND_MEM); pm_ops->finish(PM_SUSPEND_MEM);
......
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