mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 15:10:38 +00: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<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>
This commit is contained in:
parent
0245b3e787
commit
eb9289eb20
@ -158,7 +158,15 @@ int acpi_suspend(u32 acpi_state)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int acpi_pm_state_valid(suspend_state_t pm_state)
|
||||||
|
{
|
||||||
|
u32 acpi_state = acpi_suspend_states[pm_state];
|
||||||
|
|
||||||
|
return sleep_states[acpi_state];
|
||||||
|
}
|
||||||
|
|
||||||
static struct pm_ops acpi_pm_ops = {
|
static struct pm_ops acpi_pm_ops = {
|
||||||
|
.valid = acpi_pm_state_valid,
|
||||||
.prepare = acpi_pm_prepare,
|
.prepare = acpi_pm_prepare,
|
||||||
.enter = acpi_pm_enter,
|
.enter = acpi_pm_enter,
|
||||||
.finish = acpi_pm_finish,
|
.finish = acpi_pm_finish,
|
||||||
|
@ -170,6 +170,7 @@ typedef int __bitwise suspend_disk_method_t;
|
|||||||
|
|
||||||
struct pm_ops {
|
struct pm_ops {
|
||||||
suspend_disk_method_t pm_disk_mode;
|
suspend_disk_method_t pm_disk_mode;
|
||||||
|
int (*valid)(suspend_state_t state);
|
||||||
int (*prepare)(suspend_state_t state);
|
int (*prepare)(suspend_state_t state);
|
||||||
int (*enter)(suspend_state_t state);
|
int (*enter)(suspend_state_t state);
|
||||||
int (*finish)(suspend_state_t state);
|
int (*finish)(suspend_state_t state);
|
||||||
|
@ -167,6 +167,8 @@ static int enter_state(suspend_state_t state)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
if (pm_ops->valid && !pm_ops->valid(state))
|
||||||
|
return -ENODEV;
|
||||||
if (down_trylock(&pm_sem))
|
if (down_trylock(&pm_sem))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
@ -236,7 +238,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf)
|
|||||||
char * s = buf;
|
char * s = buf;
|
||||||
|
|
||||||
for (i = 0; i < PM_SUSPEND_MAX; i++) {
|
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,"%s ",pm_states[i]);
|
||||||
}
|
}
|
||||||
s += sprintf(s,"\n");
|
s += sprintf(s,"\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user