summaryrefslogtreecommitdiffstats
path: root/kernel/power/main.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-26 13:40:53 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-26 13:40:53 +0200
commit43e8317b0bba1d6eb85f38a4a233d82d7c20d732 (patch)
tree9598176b6c0c0660df93541b1bd5f4ccc5ad450c /kernel/power/main.c
parentPM / sleep: Add state field to pm_states[] entries (diff)
downloadlinux-43e8317b0bba1d6eb85f38a4a233d82d7c20d732.tar.xz
linux-43e8317b0bba1d6eb85f38a4a233d82d7c20d732.zip
PM / sleep: Use valid_state() for platform-dependent sleep states only
Use the observation that, for platform-dependent sleep states (PM_SUSPEND_STANDBY, PM_SUSPEND_MEM), a given state is either always supported or always unsupported and store that information in pm_states[] instead of calling valid_state() every time we need to check it. Also do not use valid_state() for PM_SUSPEND_FREEZE, which is always valid, and move the pm_test_level validity check for PM_SUSPEND_FREEZE directly into enter_state(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r--kernel/power/main.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 8e818432253c..9f51f0ab3d86 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -296,7 +296,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
suspend_state_t i;
for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
- if (valid_state(i))
+ if (pm_states[i].state)
s += sprintf(s,"%s ", pm_states[i].label);
#endif
@@ -328,8 +328,9 @@ static suspend_state_t decode_state(const char *buf, size_t n)
#ifdef CONFIG_SUSPEND
for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++)
- if (len == strlen(s->label) && !strncmp(buf, s->label, len))
- return state;
+ if (s->state && len == strlen(s->label)
+ && !strncmp(buf, s->label, len))
+ return s->state;
#endif
return PM_SUSPEND_ON;
@@ -447,7 +448,7 @@ static ssize_t autosleep_show(struct kobject *kobj,
#ifdef CONFIG_SUSPEND
if (state < PM_SUSPEND_MAX)
- return sprintf(buf, "%s\n", valid_state(state) ?
+ return sprintf(buf, "%s\n", pm_states[state].state ?
pm_states[state].label : "error");
#endif
#ifdef CONFIG_HIBERNATION