diff options
-rw-r--r-- | Documentation/power/interface.txt | 8 | ||||
-rw-r--r-- | kernel/power/disk.c | 29 |
2 files changed, 34 insertions, 3 deletions
diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt index 8c5b41bf3f36..fd5192a8fa8a 100644 --- a/Documentation/power/interface.txt +++ b/Documentation/power/interface.txt | |||
@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then, | |||
34 | we are able to look in the log messages and work out, for example, which code | 34 | we are able to look in the log messages and work out, for example, which code |
35 | is being slow and which device drivers are misbehaving. | 35 | is being slow and which device drivers are misbehaving. |
36 | 36 | ||
37 | Reading from this file will display what the mode is currently set | 37 | Reading from this file will display all supported modes and the currently |
38 | to. Writing to this file will accept one of | 38 | selected one in brackets, for example |
39 | |||
40 | [shutdown] reboot test testproc | ||
41 | |||
42 | Writing to this file will accept one of | ||
39 | 43 | ||
40 | 'platform' (only if the platform supports it) | 44 | 'platform' (only if the platform supports it) |
41 | 'shutdown' | 45 | 'shutdown' |
diff --git a/kernel/power/disk.c b/kernel/power/disk.c index e518379b667a..06331374d862 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c | |||
@@ -350,7 +350,34 @@ static const char * const pm_disk_modes[] = { | |||
350 | 350 | ||
351 | static ssize_t disk_show(struct kset *kset, char *buf) | 351 | static ssize_t disk_show(struct kset *kset, char *buf) |
352 | { | 352 | { |
353 | return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]); | 353 | int i; |
354 | char *start = buf; | ||
355 | |||
356 | for (i = PM_DISK_PLATFORM; i < PM_DISK_MAX; i++) { | ||
357 | if (!pm_disk_modes[i]) | ||
358 | continue; | ||
359 | switch (i) { | ||
360 | case PM_DISK_SHUTDOWN: | ||
361 | case PM_DISK_REBOOT: | ||
362 | case PM_DISK_TEST: | ||
363 | case PM_DISK_TESTPROC: | ||
364 | break; | ||
365 | default: | ||
366 | if (pm_ops && pm_ops->enter && | ||
367 | (i == pm_ops->pm_disk_mode)) | ||
368 | break; | ||
369 | /* not a valid mode, continue with loop */ | ||
370 | continue; | ||
371 | } | ||
372 | if (i == pm_disk_mode) | ||
373 | buf += sprintf(buf, "[%s]", pm_disk_modes[i]); | ||
374 | else | ||
375 | buf += sprintf(buf, "%s", pm_disk_modes[i]); | ||
376 | if (i+1 != PM_DISK_MAX) | ||
377 | buf += sprintf(buf, " "); | ||
378 | } | ||
379 | buf += sprintf(buf, "\n"); | ||
380 | return buf-start; | ||
354 | } | 381 | } |
355 | 382 | ||
356 | 383 | ||