[PATCH] fix swsusp on machines not supporting S4

From: Pavel Machek
Date: Tue Nov 29 2005 - 10:11:39 EST


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: Pavel Machek <pavel@xxxxxxx>

---
commit 72936ce37893098af1e2ec30b95274ca721bbf82
tree 5b6aaf5cd5402bfc19b3faeab179c88803756805
parent 3248196034f5f0a93554b441bd41af2620afa635
author <pavel@amd.(none)> Tue, 29 Nov 2005 16:05:14 +0100
committer <pavel@amd.(none)> Tue, 29 Nov 2005 16:05:14 +0100

kernel/power/main.c | 21 ++++++++++++++++-----
kernel/power/power.h | 3 ---
2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -24,7 +24,7 @@

DECLARE_MUTEX(pm_sem);

-struct pm_ops * pm_ops = NULL;
+struct pm_ops *pm_ops = NULL;
suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;

/**
@@ -151,6 +151,18 @@ static char *pm_states[PM_SUSPEND_MAX] =
#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.
@@ -167,7 +179,7 @@ static int enter_state(suspend_state_t s
{
int error;

- if (pm_ops && pm_ops->valid && !pm_ops->valid(state))
+ if (!valid_state(state))
return -ENODEV;
if (down_trylock(&pm_sem))
return -EBUSY;
@@ -238,9 +250,8 @@ static ssize_t state_show(struct subsyst
char * s = buf;

for (i = 0; i < PM_SUSPEND_MAX; i++) {
- if (pm_states[i] && pm_ops && (!pm_ops->valid
- ||(pm_ops->valid && pm_ops->valid(i))))
- s += sprintf(s,"%s ",pm_states[i]);
+ if (pm_states[i] && valid_state(i))
+ s += sprintf(s,"%s ", pm_states[i]);
}
s += sprintf(s,"\n");
return (s - buf);

--
Thanks, Sharp!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/