diff options
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r-- | kernel/power/main.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index 6271bc4073ef..573410d6647e 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -279,26 +279,26 @@ static inline void pm_print_times_init(void) {} | |||
279 | struct kobject *power_kobj; | 279 | struct kobject *power_kobj; |
280 | 280 | ||
281 | /** | 281 | /** |
282 | * state - control system power state. | 282 | * state - control system sleep states. |
283 | * | 283 | * |
284 | * show() returns what states are supported, which is hard-coded to | 284 | * show() returns available sleep state labels, which may be "mem", "standby", |
285 | * 'freeze' (Low-Power Idle), 'standby' (Power-On Suspend), | 285 | * "freeze" and "disk" (hibernation). See Documentation/power/states.txt for a |
286 | * 'mem' (Suspend-to-RAM), and 'disk' (Suspend-to-Disk). | 286 | * description of what they mean. |
287 | * | 287 | * |
288 | * store() accepts one of those strings, translates it into the | 288 | * store() accepts one of those strings, translates it into the proper |
289 | * proper enumerated value, and initiates a suspend transition. | 289 | * enumerated value, and initiates a suspend transition. |
290 | */ | 290 | */ |
291 | static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, | 291 | static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, |
292 | char *buf) | 292 | char *buf) |
293 | { | 293 | { |
294 | char *s = buf; | 294 | char *s = buf; |
295 | #ifdef CONFIG_SUSPEND | 295 | #ifdef CONFIG_SUSPEND |
296 | int i; | 296 | suspend_state_t i; |
297 | |||
298 | for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) | ||
299 | if (pm_states[i].state) | ||
300 | s += sprintf(s,"%s ", pm_states[i].label); | ||
297 | 301 | ||
298 | for (i = 0; i < PM_SUSPEND_MAX; i++) { | ||
299 | if (pm_states[i] && valid_state(i)) | ||
300 | s += sprintf(s,"%s ", pm_states[i]); | ||
301 | } | ||
302 | #endif | 302 | #endif |
303 | #ifdef CONFIG_HIBERNATION | 303 | #ifdef CONFIG_HIBERNATION |
304 | s += sprintf(s, "%s\n", "disk"); | 304 | s += sprintf(s, "%s\n", "disk"); |
@@ -314,7 +314,7 @@ static suspend_state_t decode_state(const char *buf, size_t n) | |||
314 | { | 314 | { |
315 | #ifdef CONFIG_SUSPEND | 315 | #ifdef CONFIG_SUSPEND |
316 | suspend_state_t state = PM_SUSPEND_MIN; | 316 | suspend_state_t state = PM_SUSPEND_MIN; |
317 | const char * const *s; | 317 | struct pm_sleep_state *s; |
318 | #endif | 318 | #endif |
319 | char *p; | 319 | char *p; |
320 | int len; | 320 | int len; |
@@ -328,8 +328,9 @@ static suspend_state_t decode_state(const char *buf, size_t n) | |||
328 | 328 | ||
329 | #ifdef CONFIG_SUSPEND | 329 | #ifdef CONFIG_SUSPEND |
330 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) | 330 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) |
331 | if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) | 331 | if (s->state && len == strlen(s->label) |
332 | return state; | 332 | && !strncmp(buf, s->label, len)) |
333 | return s->state; | ||
333 | #endif | 334 | #endif |
334 | 335 | ||
335 | return PM_SUSPEND_ON; | 336 | return PM_SUSPEND_ON; |
@@ -447,8 +448,8 @@ static ssize_t autosleep_show(struct kobject *kobj, | |||
447 | 448 | ||
448 | #ifdef CONFIG_SUSPEND | 449 | #ifdef CONFIG_SUSPEND |
449 | if (state < PM_SUSPEND_MAX) | 450 | if (state < PM_SUSPEND_MAX) |
450 | return sprintf(buf, "%s\n", valid_state(state) ? | 451 | return sprintf(buf, "%s\n", pm_states[state].state ? |
451 | pm_states[state] : "error"); | 452 | pm_states[state].label : "error"); |
452 | #endif | 453 | #endif |
453 | #ifdef CONFIG_HIBERNATION | 454 | #ifdef CONFIG_HIBERNATION |
454 | return sprintf(buf, "disk\n"); | 455 | return sprintf(buf, "disk\n"); |