提交 123d3c13 编写于 作者: P Pavel Machek 提交者: Linus Torvalds

[PATCH] fix swsusp on machines not supporting S4

Fix swsusp on machines not supporting S4.  With recent changes, it is not
possible to trigger it using /sys filesystem.  Swsusp does not really need
any support from low-level code, it is possible to reboot or halt at the
end of suspend.
Signed-off-by: NPavel Machek <pavel@suse.cz>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 d91b14c4
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
DECLARE_MUTEX(pm_sem); DECLARE_MUTEX(pm_sem);
struct pm_ops * pm_ops = NULL; struct pm_ops *pm_ops;
suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN; suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
/** /**
...@@ -151,6 +151,18 @@ static char *pm_states[PM_SUSPEND_MAX] = { ...@@ -151,6 +151,18 @@ static char *pm_states[PM_SUSPEND_MAX] = {
#endif #endif
}; };
static inline int valid_state(suspend_state_t state)
{
/* Suspend-to-disk does not really need low-level support.
* It can work with reboot if needed. */
if (state == PM_SUSPEND_DISK)
return 1;
if (pm_ops && pm_ops->valid && !pm_ops->valid(state))
return 0;
return 1;
}
/** /**
* enter_state - Do common work of entering low-power state. * enter_state - Do common work of entering low-power state.
...@@ -167,7 +179,7 @@ static int enter_state(suspend_state_t state) ...@@ -167,7 +179,7 @@ static int enter_state(suspend_state_t state)
{ {
int error; int error;
if (pm_ops && pm_ops->valid && !pm_ops->valid(state)) if (!valid_state(state))
return -ENODEV; return -ENODEV;
if (down_trylock(&pm_sem)) if (down_trylock(&pm_sem))
return -EBUSY; return -EBUSY;
...@@ -238,9 +250,8 @@ static ssize_t state_show(struct subsystem * subsys, char * buf) ...@@ -238,9 +250,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] && pm_ops && (!pm_ops->valid if (pm_states[i] && valid_state(i))
||(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");
return (s - buf); return (s - buf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册