Skip to content

Commit

Permalink
PM core: rename suspend and resume functions
Browse files Browse the repository at this point in the history
This patch (as1241) renames a bunch of functions in the PM core.
Rather than go through a boring list of name changes, suffice it to
say that in the end we have a bunch of pairs of functions:

	device_resume_noirq	dpm_resume_noirq
	device_resume		dpm_resume
	device_complete		dpm_complete
	device_suspend_noirq	dpm_suspend_noirq
	device_suspend		dpm_suspend
	device_prepare		dpm_prepare

in which device_X does the X operation on a single device and dpm_X
invokes device_X for all devices in the dpm_list.

In addition, the old dpm_power_up and device_resume_noirq have been
combined into a single function (dpm_resume_noirq).

Lastly, dpm_suspend_start and dpm_resume_end are the renamed versions
of the former top-level device_suspend and device_resume routines.

Signed-off-by: Alan Stern <[email protected]>
Acked-by: Magnus Damm <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
AlanStern authored and rjwysocki committed Jun 12, 2009
1 parent e39a71e commit d161630
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 93 deletions.
14 changes: 7 additions & 7 deletions arch/x86/kernel/apm_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,9 @@ static int suspend(int vetoable)
int err;
struct apm_user *as;

device_suspend(PMSG_SUSPEND);
dpm_suspend_start(PMSG_SUSPEND);

device_suspend_noirq(PMSG_SUSPEND);
dpm_suspend_noirq(PMSG_SUSPEND);

local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
Expand All @@ -1259,9 +1259,9 @@ static int suspend(int vetoable)
sysdev_resume();
local_irq_enable();

device_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(PMSG_RESUME);

device_resume(PMSG_RESUME);
dpm_resume_end(PMSG_RESUME);
queue_event(APM_NORMAL_RESUME, NULL);
spin_lock(&user_list_lock);
for (as = user_list; as != NULL; as = as->next) {
Expand All @@ -1277,7 +1277,7 @@ static void standby(void)
{
int err;

device_suspend_noirq(PMSG_SUSPEND);
dpm_suspend_noirq(PMSG_SUSPEND);

local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
Expand All @@ -1291,7 +1291,7 @@ static void standby(void)
sysdev_resume();
local_irq_enable();

device_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(PMSG_RESUME);
}

static apm_event_t get_event(void)
Expand Down Expand Up @@ -1376,7 +1376,7 @@ static void check_events(void)
ignore_bounce = 1;
if ((event != APM_NORMAL_RESUME)
|| (ignore_normal_resume == 0)) {
device_resume(PMSG_RESUME);
dpm_resume_end(PMSG_RESUME);
queue_event(event, NULL);
}
ignore_normal_resume = 0;
Expand Down
80 changes: 34 additions & 46 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ static void pm_dev_err(struct device *dev, pm_message_t state, char *info,
/*------------------------- Resume routines -------------------------*/

/**
* __device_resume_noirq - Power on one device (early resume).
* device_resume_noirq - Power on one device (early resume).
* @dev: Device.
* @state: PM transition of the system being carried out.
*
* Must be called with interrupts disabled.
*/
static int __device_resume_noirq(struct device *dev, pm_message_t state)
static int device_resume_noirq(struct device *dev, pm_message_t state)
{
int error = 0;

Expand All @@ -344,16 +344,16 @@ static int __device_resume_noirq(struct device *dev, pm_message_t state)
}

/**
* dpm_power_up - Power on all regular (non-sysdev) devices.
* dpm_resume_noirq - Power on all regular (non-sysdev) devices.
* @state: PM transition of the system being carried out.
*
* Execute the appropriate "noirq resume" callback for all devices marked
* as DPM_OFF_IRQ.
* Call the "noirq" resume handlers for all devices marked as
* DPM_OFF_IRQ and enable device drivers to receive interrupts.
*
* Must be called under dpm_list_mtx. Device drivers should not receive
* interrupts while it's being executed.
*/
static void dpm_power_up(pm_message_t state)
void dpm_resume_noirq(pm_message_t state)
{
struct device *dev;

Expand All @@ -363,33 +363,21 @@ static void dpm_power_up(pm_message_t state)
int error;

dev->power.status = DPM_OFF;
error = __device_resume_noirq(dev, state);
error = device_resume_noirq(dev, state);
if (error)
pm_dev_err(dev, state, " early", error);
}
mutex_unlock(&dpm_list_mtx);
}

/**
* device_resume_noirq - Turn on all devices that need special attention.
* @state: PM transition of the system being carried out.
*
* Call the "early" resume handlers and enable device drivers to receive
* interrupts.
*/
void device_resume_noirq(pm_message_t state)
{
dpm_power_up(state);
resume_device_irqs();
}
EXPORT_SYMBOL_GPL(device_resume_noirq);
EXPORT_SYMBOL_GPL(dpm_resume_noirq);

/**
* resume_device - Restore state for one device.
* device_resume - Restore state for one device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
static int resume_device(struct device *dev, pm_message_t state)
static int device_resume(struct device *dev, pm_message_t state)
{
int error = 0;

Expand Down Expand Up @@ -462,7 +450,7 @@ static void dpm_resume(pm_message_t state)
dev->power.status = DPM_RESUMING;
mutex_unlock(&dpm_list_mtx);

error = resume_device(dev, state);
error = device_resume(dev, state);

mutex_lock(&dpm_list_mtx);
if (error)
Expand All @@ -480,11 +468,11 @@ static void dpm_resume(pm_message_t state)
}

/**
* complete_device - Complete a PM transition for given device
* device_complete - Complete a PM transition for given device
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
static void complete_device(struct device *dev, pm_message_t state)
static void device_complete(struct device *dev, pm_message_t state)
{
down(&dev->sem);

Expand Down Expand Up @@ -527,7 +515,7 @@ static void dpm_complete(pm_message_t state)
dev->power.status = DPM_ON;
mutex_unlock(&dpm_list_mtx);

complete_device(dev, state);
device_complete(dev, state);

mutex_lock(&dpm_list_mtx);
}
Expand All @@ -540,19 +528,19 @@ static void dpm_complete(pm_message_t state)
}

/**
* device_resume - Restore state of each device in system.
* dpm_resume_end - Restore state of each device in system.
* @state: PM transition of the system being carried out.
*
* Resume all the devices, unlock them all, and allow new
* devices to be registered once again.
*/
void device_resume(pm_message_t state)
void dpm_resume_end(pm_message_t state)
{
might_sleep();
dpm_resume(state);
dpm_complete(state);
}
EXPORT_SYMBOL_GPL(device_resume);
EXPORT_SYMBOL_GPL(dpm_resume_end);


/*------------------------- Suspend routines -------------------------*/
Expand All @@ -577,13 +565,13 @@ static pm_message_t resume_event(pm_message_t sleep_state)
}

/**
* __device_suspend_noirq - Shut down one device (late suspend).
* device_suspend_noirq - Shut down one device (late suspend).
* @dev: Device.
* @state: PM transition of the system being carried out.
*
* This is called with interrupts off and only a single CPU running.
*/
static int __device_suspend_noirq(struct device *dev, pm_message_t state)
static int device_suspend_noirq(struct device *dev, pm_message_t state)
{
int error = 0;

Expand All @@ -602,23 +590,23 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state)
}

/**
* device_suspend_noirq - Shut down special devices.
* dpm_suspend_noirq - Power down all regular (non-sysdev) devices.
* @state: PM transition of the system being carried out.
*
* Prevent device drivers from receiving interrupts and call the "late"
* Prevent device drivers from receiving interrupts and call the "noirq"
* suspend handlers.
*
* Must be called under dpm_list_mtx.
*/
int device_suspend_noirq(pm_message_t state)
int dpm_suspend_noirq(pm_message_t state)
{
struct device *dev;
int error = 0;

suspend_device_irqs();
mutex_lock(&dpm_list_mtx);
list_for_each_entry_reverse(dev, &dpm_list, power.entry) {
error = __device_suspend_noirq(dev, state);
error = device_suspend_noirq(dev, state);
if (error) {
pm_dev_err(dev, state, " late", error);
break;
Expand All @@ -627,17 +615,17 @@ int device_suspend_noirq(pm_message_t state)
}
mutex_unlock(&dpm_list_mtx);
if (error)
device_resume_noirq(resume_event(state));
dpm_resume_noirq(resume_event(state));
return error;
}
EXPORT_SYMBOL_GPL(device_suspend_noirq);
EXPORT_SYMBOL_GPL(dpm_suspend_noirq);

/**
* suspend_device - Save state of one device.
* device_suspend - Save state of one device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
static int suspend_device(struct device *dev, pm_message_t state)
static int device_suspend(struct device *dev, pm_message_t state)
{
int error = 0;

Expand Down Expand Up @@ -704,7 +692,7 @@ static int dpm_suspend(pm_message_t state)
get_device(dev);
mutex_unlock(&dpm_list_mtx);

error = suspend_device(dev, state);
error = device_suspend(dev, state);

mutex_lock(&dpm_list_mtx);
if (error) {
Expand All @@ -723,11 +711,11 @@ static int dpm_suspend(pm_message_t state)
}

/**
* prepare_device - Execute the ->prepare() callback(s) for given device.
* device_prepare - Execute the ->prepare() callback(s) for given device.
* @dev: Device.
* @state: PM transition of the system being carried out.
*/
static int prepare_device(struct device *dev, pm_message_t state)
static int device_prepare(struct device *dev, pm_message_t state)
{
int error = 0;

Expand Down Expand Up @@ -781,7 +769,7 @@ static int dpm_prepare(pm_message_t state)
dev->power.status = DPM_PREPARING;
mutex_unlock(&dpm_list_mtx);

error = prepare_device(dev, state);
error = device_prepare(dev, state);

mutex_lock(&dpm_list_mtx);
if (error) {
Expand All @@ -807,12 +795,12 @@ static int dpm_prepare(pm_message_t state)
}

/**
* device_suspend - Save state and stop all devices in system.
* dpm_suspend_start - Save state and stop all devices in system.
* @state: PM transition of the system being carried out.
*
* Prepare and suspend all devices.
*/
int device_suspend(pm_message_t state)
int dpm_suspend_start(pm_message_t state)
{
int error;

Expand All @@ -822,7 +810,7 @@ int device_suspend(pm_message_t state)
error = dpm_suspend(state);
return error;
}
EXPORT_SYMBOL_GPL(device_suspend);
EXPORT_SYMBOL_GPL(dpm_suspend_start);

void __suspend_report_result(const char *function, void *fn, int ret)
{
Expand Down
16 changes: 8 additions & 8 deletions drivers/xen/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int xen_suspend(void *data)
if (err) {
printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
err);
device_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(PMSG_RESUME);
return err;
}

Expand All @@ -69,7 +69,7 @@ static int xen_suspend(void *data)
}

sysdev_resume();
device_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(PMSG_RESUME);

return 0;
}
Expand All @@ -92,18 +92,18 @@ static void do_suspend(void)
}
#endif

err = device_suspend(PMSG_SUSPEND);
err = dpm_suspend_start(PMSG_SUSPEND);
if (err) {
printk(KERN_ERR "xen suspend: device_suspend %d\n", err);
printk(KERN_ERR "xen suspend: dpm_suspend_start %d\n", err);
goto out;
}

printk(KERN_DEBUG "suspending xenstore...\n");
xs_suspend();

err = device_suspend_noirq(PMSG_SUSPEND);
err = dpm_suspend_noirq(PMSG_SUSPEND);
if (err) {
printk(KERN_ERR "device_suspend_noirq failed: %d\n", err);
printk(KERN_ERR "dpm_suspend_noirq failed: %d\n", err);
goto resume_devices;
}

Expand All @@ -119,10 +119,10 @@ static void do_suspend(void)
} else
xs_suspend_cancel();

device_resume_noirq(PMSG_RESUME);
dpm_resume_noirq(PMSG_RESUME);

resume_devices:
device_resume(PMSG_RESUME);
dpm_resume_end(PMSG_RESUME);

/* Make sure timer events get retriggered on all CPUs */
clock_was_set();
Expand Down
11 changes: 5 additions & 6 deletions include/linux/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,13 @@ struct dev_pm_info {
#ifdef CONFIG_PM_SLEEP
extern void device_pm_lock(void);
extern int sysdev_resume(void);
extern void device_resume_noirq(pm_message_t state);
extern void device_resume(pm_message_t state);
extern void dpm_resume_noirq(pm_message_t state);
extern void dpm_resume_end(pm_message_t state);

extern void device_pm_unlock(void);
extern int sysdev_suspend(pm_message_t state);
extern int device_suspend_noirq(pm_message_t state);
extern int device_suspend(pm_message_t state);
extern int device_prepare_suspend(pm_message_t state);
extern int dpm_suspend_noirq(pm_message_t state);
extern int dpm_suspend_start(pm_message_t state);

extern void __suspend_report_result(const char *function, void *fn, int ret);

Expand All @@ -403,7 +402,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
#define device_pm_lock() do {} while (0)
#define device_pm_unlock() do {} while (0)

static inline int device_suspend(pm_message_t state)
static inline int dpm_suspend_start(pm_message_t state)
{
return 0;
}
Expand Down
Loading

0 comments on commit d161630

Please sign in to comment.