aboutsummaryrefslogtreecommitdiff
path: root/kernel/power
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2005-10-30 15:00:01 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 17:37:15 -0800
commiteb9289eb20df6b54214c45ac7c6bf5179a149026 (patch)
treedac51cecdd94e0c7273c990259ddd800057311b9 /kernel/power
parent0245b3e787dc3267a915e1f56419e7e9c197e148 (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>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 22bdc93cc03..18d7d693fbb 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -167,6 +167,8 @@ static int enter_state(suspend_state_t state)
{
int error;
+ if (pm_ops->valid && !pm_ops->valid(state))
+ return -ENODEV;
if (down_trylock(&pm_sem))
return -EBUSY;
@@ -236,7 +238,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf)
char * s = buf;
for (i = 0; i < PM_SUSPEND_MAX; i++) {
- if (pm_states[i])
+ if (pm_states[i] && pm_ops && (!pm_ops->valid
+ ||(pm_ops->valid && pm_ops->valid(i))))
s += sprintf(s,"%s ",pm_states[i]);
}
s += sprintf(s,"\n");