]>
Commit | Line | Data |
---|---|---|
1 | From f45eb74cf9936d37dd91d28ccca865daa603eaae Mon Sep 17 00:00:00 2001 | |
2 | From: Rafael J. Wysocki <rjw@sisk.pl> | |
3 | Date: Mon, 3 Nov 2008 19:01:02 +0900 | |
4 | Subject: [PATCH] Hibernation: Introduce system_entering_hibernation | |
5 | References: bnc#441721 | |
6 | ||
7 | Introduce boolean function system_entering_hibernation() returning | |
8 | 'true' during the last phase of hibernation, in which devices are | |
9 | being put into low power states and the sleep state (for example, | |
10 | ACPI S4) is finally entered. | |
11 | ||
12 | Some device drivers need such a function to check if the system is | |
13 | in the final phase of hibernation. In particular, some SATA drivers | |
14 | are going to use it for blacklisting systems in which the disks | |
15 | should not be spun down during the last phase of hibernation (the | |
16 | BIOS will do that anyway). | |
17 | ||
18 | Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> | |
19 | Signed-off-by: Tejun Heo <tj@kernel.org> | |
20 | Signed-off-by: Jeff Garzik <jgarzik@redhat.com> | |
21 | Signed-off-by: Tejun Heo <teheo@suse.de> | |
22 | --- | |
23 | include/linux/suspend.h | 2 ++ | |
24 | kernel/power/disk.c | 10 ++++++++++ | |
25 | 2 files changed, 12 insertions(+) | |
26 | ||
27 | Index: linux-2.6.27/include/linux/suspend.h | |
28 | =================================================================== | |
29 | --- linux-2.6.27.orig/include/linux/suspend.h | |
30 | +++ linux-2.6.27/include/linux/suspend.h | |
31 | @@ -232,6 +232,7 @@ extern unsigned long get_safe_page(gfp_t | |
32 | ||
33 | extern void hibernation_set_ops(struct platform_hibernation_ops *ops); | |
34 | extern int hibernate(void); | |
35 | +extern bool system_entering_hibernation(void); | |
36 | #else /* CONFIG_HIBERNATION */ | |
37 | static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } | |
38 | static inline void swsusp_set_page_free(struct page *p) {} | |
39 | @@ -239,6 +240,7 @@ static inline void swsusp_unset_page_fre | |
40 | ||
41 | static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {} | |
42 | static inline int hibernate(void) { return -ENOSYS; } | |
43 | +static inline bool system_entering_hibernation(void) { return false; } | |
44 | #endif /* CONFIG_HIBERNATION */ | |
45 | ||
46 | #ifdef CONFIG_PM_SLEEP | |
47 | Index: linux-2.6.27/kernel/power/disk.c | |
48 | =================================================================== | |
49 | --- linux-2.6.27.orig/kernel/power/disk.c | |
50 | +++ linux-2.6.27/kernel/power/disk.c | |
51 | @@ -71,6 +71,14 @@ void hibernation_set_ops(struct platform | |
52 | mutex_unlock(&pm_mutex); | |
53 | } | |
54 | ||
55 | +static bool entering_platform_hibernation; | |
56 | + | |
57 | +bool system_entering_hibernation(void) | |
58 | +{ | |
59 | + return entering_platform_hibernation; | |
60 | +} | |
61 | +EXPORT_SYMBOL_GPL(system_entering_hibernation); | |
62 | + | |
63 | #ifdef CONFIG_PM_DEBUG | |
64 | static void hibernation_debug_sleep(void) | |
65 | { | |
66 | @@ -415,6 +423,7 @@ int hibernation_platform_enter(void) | |
67 | if (error) | |
68 | goto Close; | |
69 | ||
70 | + entering_platform_hibernation = true; | |
71 | suspend_console(); | |
72 | ftrace_save = __ftrace_enabled_save(); | |
73 | error = device_suspend(PMSG_HIBERNATE); | |
74 | @@ -450,6 +459,7 @@ int hibernation_platform_enter(void) | |
75 | Finish: | |
76 | hibernation_ops->finish(); | |
77 | Resume_devices: | |
78 | + entering_platform_hibernation = false; | |
79 | device_resume(PMSG_RESTORE); | |
80 | __ftrace_enabled_restore(ftrace_save); | |
81 | resume_console(); |