X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=kernel%2Fpower%2Fdisk.c;h=14a656cdc6523bf64d9c5b64c3a628529b56bab5;hb=198bb971e256e4167e45e7df643c13ea66f67e3a;hp=64e42ab8b57c3008e5d1f1574557eef3667939d7;hpb=23976728a48c3b76d34e17ead19addd52b3a280e;p=linux-2.6 diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 64e42ab8b5..14a656cdc6 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -26,7 +26,7 @@ static int noresume = 0; -char resume_file[256] = CONFIG_PM_STD_PARTITION; +static char resume_file[256] = CONFIG_PM_STD_PARTITION; dev_t swsusp_resume_device; sector_t swsusp_resume_block; @@ -54,8 +54,8 @@ static struct platform_hibernation_ops *hibernation_ops; void hibernation_set_ops(struct platform_hibernation_ops *ops) { - if (ops && !(ops->start && ops->pre_snapshot && ops->finish - && ops->prepare && ops->enter && ops->pre_restore + if (ops && !(ops->begin && ops->end && ops->pre_snapshot + && ops->prepare && ops->finish && ops->enter && ops->pre_restore && ops->restore_cleanup)) { WARN_ON(1); return; @@ -100,14 +100,25 @@ static int hibernation_test(int level) { return 0; } #endif /* !CONFIG_PM_DEBUG */ /** - * platform_start - tell the platform driver that we're starting + * platform_begin - tell the platform driver that we're starting * hibernation */ -static int platform_start(int platform_mode) +static int platform_begin(int platform_mode) { return (platform_mode && hibernation_ops) ? - hibernation_ops->start() : 0; + hibernation_ops->begin() : 0; +} + +/** + * platform_end - tell the platform driver that we've entered the + * working state + */ + +static void platform_end(int platform_mode) +{ + if (platform_mode && hibernation_ops) + hibernation_ops->end(); } /** @@ -174,7 +185,7 @@ static void platform_restore_cleanup(int platform_mode) * reappears in this routine after a restore. */ -int create_image(int platform_mode) +static int create_image(int platform_mode) { int error; @@ -237,9 +248,9 @@ int hibernation_snapshot(int platform_mode) if (error) return error; - error = platform_start(platform_mode); + error = platform_begin(platform_mode); if (error) - return error; + goto Close; suspend_console(); error = device_suspend(PMSG_FREEZE); @@ -272,6 +283,8 @@ int hibernation_snapshot(int platform_mode) device_resume(); Resume_console: resume_console(); + Close: + platform_end(platform_mode); return error; } @@ -373,12 +386,12 @@ int hibernation_platform_enter(void) * hibernation_ops->finish() before saving the image, so we should let * the firmware know that we're going to enter the sleep state after all */ - error = hibernation_ops->start(); + error = hibernation_ops->begin(); if (error) - return error; + goto Close; suspend_console(); - error = device_suspend(PMSG_SUSPEND); + error = device_suspend(PMSG_HIBERNATE); if (error) goto Resume_console; @@ -391,7 +404,7 @@ int hibernation_platform_enter(void) goto Finish; local_irq_disable(); - error = device_power_down(PMSG_SUSPEND); + error = device_power_down(PMSG_HIBERNATE); if (!error) { hibernation_ops->enter(); /* We should never get here */ @@ -409,6 +422,8 @@ int hibernation_platform_enter(void) device_resume(); Resume_console: resume_console(); + Close: + hibernation_ops->end(); return error; } @@ -443,20 +458,13 @@ static void power_down(void) while(1); } -static void unprepare_processes(void) -{ - thaw_processes(); - pm_restore_console(); -} - static int prepare_processes(void) { int error = 0; - pm_prepare_console(); if (freeze_processes()) { error = -EBUSY; - unprepare_processes(); + thaw_processes(); } return error; } @@ -476,6 +484,7 @@ int hibernate(void) goto Unlock; } + pm_prepare_console(); error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE); if (error) goto Exit; @@ -515,11 +524,12 @@ int hibernate(void) swsusp_free(); } Thaw: - unprepare_processes(); + thaw_processes(); Finish: free_basic_memory_bitmaps(); Exit: pm_notifier_call_chain(PM_POST_HIBERNATION); + pm_restore_console(); atomic_inc(&snapshot_device_available); Unlock: mutex_unlock(&pm_mutex); @@ -588,6 +598,7 @@ static int software_resume(void) goto Unlock; } + pm_prepare_console(); error = pm_notifier_call_chain(PM_RESTORE_PREPARE); if (error) goto Finish; @@ -611,11 +622,12 @@ static int software_resume(void) printk(KERN_ERR "PM: Restore failed, recovering.\n"); swsusp_free(); - unprepare_processes(); + thaw_processes(); Done: free_basic_memory_bitmaps(); Finish: pm_notifier_call_chain(PM_POST_RESTORE); + pm_restore_console(); atomic_inc(&snapshot_device_available); /* For success case, the suspend path will release the lock */ Unlock: