[Suspend2][ 09/16] [Suspend2] Top level routine for do_suspend.

From: Nigel Cunningham
Date: Mon Jun 26 2006 - 18:32:43 EST


Our top level routine for suspending - activate storage, check if we can
suspend, check if a kept image is still to be used (powerdown if so), then
prepare and save the image (including powering down). When we return from
save_image, we've either aborted during saving, or resumed at a later time.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/power/suspend.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index bda4c2a..40f54f7 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -599,3 +599,44 @@ static int can_suspend(void)
return 1;
}

+/*
+ * suspend_main
+ * Functionality : First level of code for software suspend invocations.
+ * Stores and restores load averages (to avoid a spike),
+ * allocates bitmaps, freezes processes and eats memory
+ * as required before suspending drivers and invoking
+ * the 'low level' code to save the state to disk.
+ * By the time we return from do_suspend2_suspend, we
+ * have either failed to save the image or successfully
+ * suspended and reloaded the image. The difference can
+ * be discerned by checking SUSPEND_ABORTED.
+ * Called From :
+ */
+void suspend_main(void)
+{
+ if (suspend_activate_storage(0))
+ return;
+
+ if (!can_suspend())
+ goto cleanup;
+
+ /*
+ * If kept image and still keeping image and suspending to RAM, we will
+ * return 1 after suspending and resuming (provided the power doesn't
+ * run out.
+ */
+ if (test_result_state(SUSPEND_KEPT_IMAGE) && check_still_keeping_image())
+ goto cleanup;
+
+
+ if (suspend_init() && !suspend_prepare_image() && !test_result_state(SUSPEND_ABORTED) &&
+ !test_action_state(SUSPEND_FREEZER_TEST)) {
+ suspend_prepare_status(DONT_CLEAR_BAR, "Starting to save the image..");
+ save_image();
+ }
+
+cleanup:
+ suspend_cleanup();
+ suspend_deactivate_storage(0);
+}
+

--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/