diff options
author | Shaohua Li <shaohua.li@intel.com> | 2005-10-30 18:00:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-30 20:37:15 -0500 |
commit | eb9289eb20df6b54214c45ac7c6bf5179a149026 (patch) | |
tree | dac51cecdd94e0c7273c990259ddd800057311b9 | |
parent | 0245b3e787dc3267a915e1f56419e7e9c197e148 (diff) |
[PATCH] introduce .valid callback for pm_ops
Add pm_ops.valid callback, so only the available pm states show in
/sys/power/state. And this also makes an earlier states error report at
enter_state before we do actual suspend/resume.
Signed-off-by: Shaohua Li<shaohua.li@intel.com>
Acked-by: Pavel Machek<pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/acpi/sleep/main.c | 8 | ||||
-rw-r--r-- | include/linux/pm.h | 1 | ||||
-rw-r--r-- | kernel/power/main.c | 5 |
3 files changed, 13 insertions, 1 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index aee50b453265..930427fc0c4b 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -158,7 +158,15 @@ int acpi_suspend(u32 acpi_state) | |||
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | } | 159 | } |
160 | 160 | ||
161 | static int acpi_pm_state_valid(suspend_state_t pm_state) | ||
162 | { | ||
163 | u32 acpi_state = acpi_suspend_states[pm_state]; | ||
164 | |||
165 | return sleep_states[acpi_state]; | ||
166 | } | ||
167 | |||
161 | static struct pm_ops acpi_pm_ops = { | 168 | static struct pm_ops acpi_pm_ops = { |
169 | .valid = acpi_pm_state_valid, | ||
162 | .prepare = acpi_pm_prepare, | 170 | .prepare = acpi_pm_prepare, |
163 | .enter = acpi_pm_enter, | 171 | .enter = acpi_pm_enter, |
164 | .finish = acpi_pm_finish, | 172 | .finish = acpi_pm_finish, |
diff --git a/include/linux/pm.h b/include/linux/pm.h index c61d5de837ef..1514098d156d 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -170,6 +170,7 @@ typedef int __bitwise suspend_disk_method_t; | |||
170 | 170 | ||
171 | struct pm_ops { | 171 | struct pm_ops { |
172 | suspend_disk_method_t pm_disk_mode; | 172 | suspend_disk_method_t pm_disk_mode; |
173 | int (*valid)(suspend_state_t state); | ||
173 | int (*prepare)(suspend_state_t state); | 174 | int (*prepare)(suspend_state_t state); |
174 | int (*enter)(suspend_state_t state); | 175 | int (*enter)(suspend_state_t state); |
175 | int (*finish)(suspend_state_t state); | 176 | int (*finish)(suspend_state_t state); |
diff --git a/kernel/power/main.c b/kernel/power/main.c index 22bdc93cc038..18d7d693fbba 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -167,6 +167,8 @@ static int enter_state(suspend_state_t state) | |||
167 | { | 167 | { |
168 | int error; | 168 | int error; |
169 | 169 | ||
170 | if (pm_ops->valid && !pm_ops->valid(state)) | ||
171 | return -ENODEV; | ||
170 | if (down_trylock(&pm_sem)) | 172 | if (down_trylock(&pm_sem)) |
171 | return -EBUSY; | 173 | return -EBUSY; |
172 | 174 | ||
@@ -236,7 +238,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf) | |||
236 | char * s = buf; | 238 | char * s = buf; |
237 | 239 | ||
238 | for (i = 0; i < PM_SUSPEND_MAX; i++) { | 240 | for (i = 0; i < PM_SUSPEND_MAX; i++) { |
239 | if (pm_states[i]) | 241 | if (pm_states[i] && pm_ops && (!pm_ops->valid |
242 | ||(pm_ops->valid && pm_ops->valid(i)))) | ||
240 | s += sprintf(s,"%s ",pm_states[i]); | 243 | s += sprintf(s,"%s ",pm_states[i]); |
241 | } | 244 | } |
242 | s += sprintf(s,"\n"); | 245 | s += sprintf(s,"\n"); |