Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82388
b: refs/heads/master
c: c697eec
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Len Brown committed Feb 1, 2008
1 parent 22a83e6 commit 9483584
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7671b8ae5381a504d4c4ef8dd9c47128c2c3fd7e
refs/heads/master: c697eecebc6cfc0b393afea3c4ff1a5041526ad1
17 changes: 13 additions & 4 deletions trunk/arch/arm/mach-at91/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static suspend_state_t target_state;
/*
* Called after processes are frozen, but before we shutdown devices.
*/
static int at91_pm_set_target(suspend_state_t state)
static int at91_pm_begin(suspend_state_t state)
{
target_state = state;
return 0;
Expand Down Expand Up @@ -202,11 +202,20 @@ static int at91_pm_enter(suspend_state_t state)
return 0;
}

/*
* Called right prior to thawing processes.
*/
static void at91_pm_end(void)
{
target_state = PM_SUSPEND_ON;
}


static struct platform_suspend_ops at91_pm_ops ={
.valid = at91_pm_valid_state,
.set_target = at91_pm_set_target,
.enter = at91_pm_enter,
.valid = at91_pm_valid_state,
.begin = at91_pm_begin,
.enter = at91_pm_enter,
.end = at91_pm_end,
};

static int __init at91_pm_init(void)
Expand Down
10 changes: 8 additions & 2 deletions trunk/arch/powerpc/platforms/52xx/lite5200_pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int lite5200_pm_valid(suspend_state_t state)
}
}

static int lite5200_pm_set_target(suspend_state_t state)
static int lite5200_pm_begin(suspend_state_t state)
{
if (lite5200_pm_valid(state)) {
lite5200_pm_target_state = state;
Expand Down Expand Up @@ -219,12 +219,18 @@ static void lite5200_pm_finish(void)
mpc52xx_pm_finish();
}

static void lite5200_pm_end(void)
{
lite5200_pm_target_state = PM_SUSPEND_ON;
}

static struct platform_suspend_ops lite5200_pm_ops = {
.valid = lite5200_pm_valid,
.set_target = lite5200_pm_set_target,
.begin = lite5200_pm_begin,
.prepare = lite5200_pm_prepare,
.enter = lite5200_pm_enter,
.finish = lite5200_pm_finish,
.end = lite5200_pm_end,
};

int __init lite5200_pm_init(void)
Expand Down
22 changes: 18 additions & 4 deletions trunk/drivers/acpi/sleep/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ static u32 acpi_suspend_states[] = {
static int init_8259A_after_S1;

/**
* acpi_pm_set_target - Set the target system sleep state to the state
* acpi_pm_begin - Set the target system sleep state to the state
* associated with given @pm_state, if supported.
*/

static int acpi_pm_set_target(suspend_state_t pm_state)
static int acpi_pm_begin(suspend_state_t pm_state)
{
u32 acpi_state = acpi_suspend_states[pm_state];
int error = 0;
Expand Down Expand Up @@ -164,7 +164,7 @@ static int acpi_pm_enter(suspend_state_t pm_state)
}

/**
* acpi_pm_finish - Finish up suspend sequence.
* acpi_pm_finish - Instruct the platform to leave a sleep state.
*
* This is called after we wake back up (or if entering the sleep state
* failed).
Expand All @@ -190,6 +190,19 @@ static void acpi_pm_finish(void)
#endif
}

/**
* acpi_pm_end - Finish up suspend sequence.
*/

static void acpi_pm_end(void)
{
/*
* This is necessary in case acpi_pm_finish() is not called during a
* failing transition to a sleep state.
*/
acpi_target_sleep_state = ACPI_STATE_S0;
}

static int acpi_pm_state_valid(suspend_state_t pm_state)
{
u32 acpi_state;
Expand All @@ -208,10 +221,11 @@ static int acpi_pm_state_valid(suspend_state_t pm_state)

static struct platform_suspend_ops acpi_pm_ops = {
.valid = acpi_pm_state_valid,
.set_target = acpi_pm_set_target,
.begin = acpi_pm_begin,
.prepare = acpi_pm_prepare,
.enter = acpi_pm_enter,
.finish = acpi_pm_finish,
.end = acpi_pm_end,
};

/*
Expand Down
29 changes: 18 additions & 11 deletions trunk/include/linux/suspend.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,25 @@ typedef int __bitwise suspend_state_t;
* There is the %suspend_valid_only_mem function available that can be
* assigned to this if the platform only supports mem sleep.
*
* @set_target: Tell the platform which system sleep state is going to be
* entered.
* @set_target() is executed right prior to suspending devices. The
* information conveyed to the platform code by @set_target() should be
* disregarded by the platform as soon as @finish() is executed and if
* @prepare() fails. If @set_target() fails (ie. returns nonzero),
* @begin: Initialise a transition to given system sleep state.
* @begin() is executed right prior to suspending devices. The information
* conveyed to the platform code by @begin() should be disregarded by it as
* soon as @end() is executed. If @begin() fails (ie. returns nonzero),
* @prepare(), @enter() and @finish() will not be called by the PM core.
* This callback is optional. However, if it is implemented, the argument
* passed to @enter() is meaningless and should be ignored.
* passed to @enter() is redundant and should be ignored.
*
* @prepare: Prepare the platform for entering the system sleep state indicated
* by @set_target().
* by @begin().
* @prepare() is called right after devices have been suspended (ie. the
* appropriate .suspend() method has been executed for each device) and
* before the nonboot CPUs are disabled (it is executed with IRQs enabled).
* This callback is optional. It returns 0 on success or a negative
* error code otherwise, in which case the system cannot enter the desired
* sleep state (@enter() and @finish() will not be called in that case).
*
* @enter: Enter the system sleep state indicated by @set_target() or
* represented by the argument if @set_target() is not implemented.
* @enter: Enter the system sleep state indicated by @begin() or represented by
* the argument if @begin() is not implemented.
* This callback is mandatory. It returns 0 on success or a negative
* error code otherwise, in which case the system cannot enter the desired
* sleep state.
Expand All @@ -69,13 +67,22 @@ typedef int __bitwise suspend_state_t;
* This callback is optional, but should be implemented by the platforms
* that implement @prepare(). If implemented, it is always called after
* @enter() (even if @enter() fails).
*
* @end: Called by the PM core right after resuming devices, to indicate to
* the platform that the system has returned to the working state or
* the transition to the sleep state has been aborted.
* This callback is optional, but should be implemented by the platforms
* that implement @begin(), but platforms implementing @begin() should
* also provide a @end() which cleans up transitions aborted before
* @enter().
*/
struct platform_suspend_ops {
int (*valid)(suspend_state_t state);
int (*set_target)(suspend_state_t state);
int (*begin)(suspend_state_t state);
int (*prepare)(void);
int (*enter)(suspend_state_t state);
void (*finish)(void);
void (*end)(void);
};

#ifdef CONFIG_SUSPEND
Expand Down
9 changes: 6 additions & 3 deletions trunk/kernel/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ int suspend_devices_and_enter(suspend_state_t state)
if (!suspend_ops)
return -ENOSYS;

if (suspend_ops->set_target) {
error = suspend_ops->set_target(state);
if (suspend_ops->begin) {
error = suspend_ops->begin(state);
if (error)
return error;
goto Close;
}
suspend_console();
error = device_suspend(PMSG_SUSPEND);
Expand Down Expand Up @@ -294,6 +294,9 @@ int suspend_devices_and_enter(suspend_state_t state)
device_resume();
Resume_console:
resume_console();
Close:
if (suspend_ops->end)
suspend_ops->end();
return error;
}

Expand Down

0 comments on commit 9483584

Please sign in to comment.