mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
[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<[email protected]> Acked-by: Pavel Machek<[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
0245b3e787
commit
eb9289eb20
3 changed files with 13 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue