diff options
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r-- | kernel/power/main.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index cfba6987ae7d..350b485b3b60 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -25,11 +25,13 @@ | |||
25 | 25 | ||
26 | BLOCKING_NOTIFIER_HEAD(pm_chain_head); | 26 | BLOCKING_NOTIFIER_HEAD(pm_chain_head); |
27 | 27 | ||
28 | /*This is just an arbitrary number */ | ||
29 | #define FREE_PAGE_NUMBER (100) | ||
30 | |||
31 | DEFINE_MUTEX(pm_mutex); | 28 | DEFINE_MUTEX(pm_mutex); |
32 | 29 | ||
30 | #ifdef CONFIG_SUSPEND | ||
31 | |||
32 | /* This is just an arbitrary number */ | ||
33 | #define FREE_PAGE_NUMBER (100) | ||
34 | |||
33 | struct pm_ops *pm_ops; | 35 | struct pm_ops *pm_ops; |
34 | 36 | ||
35 | /** | 37 | /** |
@@ -269,6 +271,8 @@ int pm_suspend(suspend_state_t state) | |||
269 | 271 | ||
270 | EXPORT_SYMBOL(pm_suspend); | 272 | EXPORT_SYMBOL(pm_suspend); |
271 | 273 | ||
274 | #endif /* CONFIG_SUSPEND */ | ||
275 | |||
272 | decl_subsys(power,NULL,NULL); | 276 | decl_subsys(power,NULL,NULL); |
273 | 277 | ||
274 | 278 | ||
@@ -285,13 +289,15 @@ decl_subsys(power,NULL,NULL); | |||
285 | 289 | ||
286 | static ssize_t state_show(struct kset *kset, char *buf) | 290 | static ssize_t state_show(struct kset *kset, char *buf) |
287 | { | 291 | { |
292 | char *s = buf; | ||
293 | #ifdef CONFIG_SUSPEND | ||
288 | int i; | 294 | int i; |
289 | char * s = buf; | ||
290 | 295 | ||
291 | for (i = 0; i < PM_SUSPEND_MAX; i++) { | 296 | for (i = 0; i < PM_SUSPEND_MAX; i++) { |
292 | if (pm_states[i] && valid_state(i)) | 297 | if (pm_states[i] && valid_state(i)) |
293 | s += sprintf(s,"%s ", pm_states[i]); | 298 | s += sprintf(s,"%s ", pm_states[i]); |
294 | } | 299 | } |
300 | #endif | ||
295 | #ifdef CONFIG_HIBERNATION | 301 | #ifdef CONFIG_HIBERNATION |
296 | s += sprintf(s, "%s\n", "disk"); | 302 | s += sprintf(s, "%s\n", "disk"); |
297 | #else | 303 | #else |
@@ -304,11 +310,13 @@ static ssize_t state_show(struct kset *kset, char *buf) | |||
304 | 310 | ||
305 | static ssize_t state_store(struct kset *kset, const char *buf, size_t n) | 311 | static ssize_t state_store(struct kset *kset, const char *buf, size_t n) |
306 | { | 312 | { |
313 | #ifdef CONFIG_SUSPEND | ||
307 | suspend_state_t state = PM_SUSPEND_STANDBY; | 314 | suspend_state_t state = PM_SUSPEND_STANDBY; |
308 | const char * const *s; | 315 | const char * const *s; |
316 | #endif | ||
309 | char *p; | 317 | char *p; |
310 | int error; | ||
311 | int len; | 318 | int len; |
319 | int error = -EINVAL; | ||
312 | 320 | ||
313 | p = memchr(buf, '\n', n); | 321 | p = memchr(buf, '\n', n); |
314 | len = p ? p - buf : n; | 322 | len = p ? p - buf : n; |
@@ -316,17 +324,19 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n) | |||
316 | /* First, check if we are requested to hibernate */ | 324 | /* First, check if we are requested to hibernate */ |
317 | if (len == 4 && !strncmp(buf, "disk", len)) { | 325 | if (len == 4 && !strncmp(buf, "disk", len)) { |
318 | error = hibernate(); | 326 | error = hibernate(); |
319 | return error ? error : n; | 327 | goto Exit; |
320 | } | 328 | } |
321 | 329 | ||
330 | #ifdef CONFIG_SUSPEND | ||
322 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { | 331 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { |
323 | if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) | 332 | if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) |
324 | break; | 333 | break; |
325 | } | 334 | } |
326 | if (state < PM_SUSPEND_MAX && *s) | 335 | if (state < PM_SUSPEND_MAX && *s) |
327 | error = enter_state(state); | 336 | error = enter_state(state); |
328 | else | 337 | #endif |
329 | error = -EINVAL; | 338 | |
339 | Exit: | ||
330 | return error ? error : n; | 340 | return error ? error : n; |
331 | } | 341 | } |
332 | 342 | ||