From 2391dae3e36c19fe668c71eac2eb8344dbaaf46d Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sun, 1 Jul 2007 12:07:33 -0700 Subject: PM: introduce set_target method in pm_ops Commit 52ade9b3b97fd3bea42842a056fe0786c28d0555 changed the suspend code ordering to execute pm_ops->prepare() after the device model per-device .suspend() calls in order to fix some ACPI-related issues. Unfortunately, it broke the at91 platform which assumed that pm_ops->prepare() would be called before suspending devices. at91 used pm_ops->prepare() to get notified of the target system sleep state, so that it could use this information while suspending devices. However, with the current suspend code ordering pm_ops->prepare() is called too late for this purpose. Thus, at91 needs an additional method in 'struct pm_ops' that will be used for notifying the platform of the target system sleep state. Moreover, in the future such a method will also be needed by ACPI. This patch adds the .set_target() method to 'struct pm_ops' and makes the suspend code call it, if implemented, before executing the device model per-device .suspend() calls. It also modifies the at91 code to use pm_ops->set_target() instead of pm_ops->prepare(). Signed-off-by: Rafael J. Wysocki Acked-by: David Brownell Cc: Pavel Machek Cc: Johannes Berg Cc: Len Brown Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'kernel') diff --git a/kernel/power/main.c b/kernel/power/main.c index 8812985f302..fc45ed22620 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -97,6 +96,11 @@ static int suspend_prepare(suspend_state_t state) } } + if (pm_ops->set_target) { + error = pm_ops->set_target(state); + if (error) + goto Thaw; + } suspend_console(); error = device_suspend(PMSG_SUSPEND); if (error) { -- cgit v1.2.3-70-g09d2