diff options
author | Pavel Machek <pavel@ucw.cz> | 2005-11-29 22:34:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-29 22:47:03 -0500 |
commit | 123d3c13e2853a11b4d599d754b356acb12886e2 (patch) | |
tree | 6127e78c2dabcb2ca70de896b7aba53f12213d82 /kernel/power | |
parent | d91b14c463306eb6527550ba48617e7f5500d3ae (diff) |
[PATCH] fix swsusp on machines not supporting S4
Fix swsusp on machines not supporting S4. With recent changes, it is not
possible to trigger it using /sys filesystem. Swsusp does not really need
any support from low-level code, it is possible to reboot or halt at the
end of suspend.
Signed-off-by: Pavel Machek <pavel@suse.cz>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/main.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index 6ee2cad530e8..d253f3ae2fa5 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | DECLARE_MUTEX(pm_sem); | 25 | DECLARE_MUTEX(pm_sem); |
26 | 26 | ||
27 | struct pm_ops * pm_ops = NULL; | 27 | struct pm_ops *pm_ops; |
28 | suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN; | 28 | suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN; |
29 | 29 | ||
30 | /** | 30 | /** |
@@ -151,6 +151,18 @@ static char *pm_states[PM_SUSPEND_MAX] = { | |||
151 | #endif | 151 | #endif |
152 | }; | 152 | }; |
153 | 153 | ||
154 | static inline int valid_state(suspend_state_t state) | ||
155 | { | ||
156 | /* Suspend-to-disk does not really need low-level support. | ||
157 | * It can work with reboot if needed. */ | ||
158 | if (state == PM_SUSPEND_DISK) | ||
159 | return 1; | ||
160 | |||
161 | if (pm_ops && pm_ops->valid && !pm_ops->valid(state)) | ||
162 | return 0; | ||
163 | return 1; | ||
164 | } | ||
165 | |||
154 | 166 | ||
155 | /** | 167 | /** |
156 | * enter_state - Do common work of entering low-power state. | 168 | * enter_state - Do common work of entering low-power state. |
@@ -167,7 +179,7 @@ static int enter_state(suspend_state_t state) | |||
167 | { | 179 | { |
168 | int error; | 180 | int error; |
169 | 181 | ||
170 | if (pm_ops && pm_ops->valid && !pm_ops->valid(state)) | 182 | if (!valid_state(state)) |
171 | return -ENODEV; | 183 | return -ENODEV; |
172 | if (down_trylock(&pm_sem)) | 184 | if (down_trylock(&pm_sem)) |
173 | return -EBUSY; | 185 | return -EBUSY; |
@@ -238,9 +250,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf) | |||
238 | char * s = buf; | 250 | char * s = buf; |
239 | 251 | ||
240 | for (i = 0; i < PM_SUSPEND_MAX; i++) { | 252 | for (i = 0; i < PM_SUSPEND_MAX; i++) { |
241 | if (pm_states[i] && pm_ops && (!pm_ops->valid | 253 | if (pm_states[i] && valid_state(i)) |
242 | ||(pm_ops->valid && pm_ops->valid(i)))) | 254 | s += sprintf(s,"%s ", pm_states[i]); |
243 | s += sprintf(s,"%s ",pm_states[i]); | ||
244 | } | 255 | } |
245 | s += sprintf(s,"\n"); | 256 | s += sprintf(s,"\n"); |
246 | return (s - buf); | 257 | return (s - buf); |