aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>2011-11-22 17:20:31 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2011-11-23 15:13:41 -0500
commit953a206393b1533ceb0e7d725cc5a8c8d7ed97dd (patch)
tree7eb6448987f474f287bd2fce66dd1fff6e2eec30 /kernel/power
parent64e94aafb6a5c4f419e9b8f93950914b5ac162a9 (diff)
PM / Hibernate: Refactor and simplify hibernation_snapshot() code
The goto statements in hibernation_snapshot() are a bit complex. Refactor the code to remove some of them, thereby simplifying the implementation. Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/hibernate.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a6b0503574ee..ebf62c3bc9f7 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -333,7 +333,7 @@ static int create_image(int platform_mode)
333 */ 333 */
334int hibernation_snapshot(int platform_mode) 334int hibernation_snapshot(int platform_mode)
335{ 335{
336 pm_message_t msg = PMSG_RECOVER; 336 pm_message_t msg;
337 int error; 337 int error;
338 338
339 error = platform_begin(platform_mode); 339 error = platform_begin(platform_mode);
@@ -362,26 +362,26 @@ int hibernation_snapshot(int platform_mode)
362 362
363 error = dpm_prepare(PMSG_FREEZE); 363 error = dpm_prepare(PMSG_FREEZE);
364 if (error) { 364 if (error) {
365 dpm_complete(msg); 365 dpm_complete(PMSG_RECOVER);
366 goto Cleanup; 366 goto Cleanup;
367 } 367 }
368 368
369 suspend_console(); 369 suspend_console();
370 pm_restrict_gfp_mask(); 370 pm_restrict_gfp_mask();
371
371 error = dpm_suspend(PMSG_FREEZE); 372 error = dpm_suspend(PMSG_FREEZE);
372 if (error)
373 goto Recover_platform;
374 373
375 if (hibernation_test(TEST_DEVICES)) 374 if (error || hibernation_test(TEST_DEVICES))
376 goto Recover_platform; 375 platform_recover(platform_mode);
376 else
377 error = create_image(platform_mode);
377 378
378 error = create_image(platform_mode);
379 /* 379 /*
380 * Control returns here (1) after the image has been created or the 380 * In the case that we call create_image() above, the control
381 * returns here (1) after the image has been created or the
381 * image creation has failed and (2) after a successful restore. 382 * image creation has failed and (2) after a successful restore.
382 */ 383 */
383 384
384 Resume_devices:
385 /* We may need to release the preallocated image pages here. */ 385 /* We may need to release the preallocated image pages here. */
386 if (error || !in_suspend) 386 if (error || !in_suspend)
387 swsusp_free(); 387 swsusp_free();
@@ -399,10 +399,6 @@ int hibernation_snapshot(int platform_mode)
399 platform_end(platform_mode); 399 platform_end(platform_mode);
400 return error; 400 return error;
401 401
402 Recover_platform:
403 platform_recover(platform_mode);
404 goto Resume_devices;
405
406 Cleanup: 402 Cleanup:
407 swsusp_free(); 403 swsusp_free();
408 goto Close; 404 goto Close;