summaryrefslogtreecommitdiffstats
path: root/kernel/power/swap.c
diff options
context:
space:
mode:
authorBojan Smojver <bojan@rexursive.com>2012-06-16 00:09:58 +0200
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-01 13:31:22 +0200
commit62c552ccc3eda1198632a4f344aa32623d226bab (patch)
treefbd85e76542a715a8e988dddb59e3df859939fb5 /kernel/power/swap.c
parent6887a4131da3adaab011613776d865f4bcfb5678 (diff)
downloadop-kernel-dev-62c552ccc3eda1198632a4f344aa32623d226bab.zip
op-kernel-dev-62c552ccc3eda1198632a4f344aa32623d226bab.tar.gz
PM / Hibernate: Enable suspend to both for in-kernel hibernation.
It is often useful to suspend to memory after hibernation image has been written to disk. If the battery runs out or power is otherwise lost, the computer will resume from the hibernated image. If not, it will resume from memory and hibernation image will be discarded. Signed-off-by: Bojan Smojver <bojan@rexursive.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power/swap.c')
-rw-r--r--kernel/power/swap.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 11e22c0..83d5051 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1472,6 +1472,34 @@ void swsusp_close(fmode_t mode)
blkdev_put(hib_resume_bdev, mode);
}
+/**
+ * swsusp_unmark - Unmark swsusp signature in the resume device
+ */
+
+#ifdef CONFIG_SUSPEND
+int swsusp_unmark(void)
+{
+ int error;
+
+ hib_bio_read_page(swsusp_resume_block, swsusp_header, NULL);
+ if (!memcmp(HIBERNATE_SIG,swsusp_header->sig, 10)) {
+ memcpy(swsusp_header->sig,swsusp_header->orig_sig, 10);
+ error = hib_bio_write_page(swsusp_resume_block,
+ swsusp_header, NULL);
+ } else {
+ printk(KERN_ERR "PM: Cannot find swsusp signature!\n");
+ error = -ENODEV;
+ }
+
+ /*
+ * We just returned from suspend, we don't need the image any more.
+ */
+ free_all_swap_pages(root_swap);
+
+ return error;
+}
+#endif
+
static int swsusp_header_init(void)
{
swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
OpenPOWER on IntegriCloud