Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1616302 authored by Alan Stern's avatar Alan Stern Committed by Rafael J. Wysocki
Browse files

PM core: rename suspend and resume functions



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: default avatarAlan Stern <stern@rowland.harvard.edu>
Acked-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent e39a71ef
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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);
@@ -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) {
@@ -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);
@@ -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)
@@ -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;
+34 −46
Original line number Diff line number Diff line
@@ -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;

@@ -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;

@@ -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;

@@ -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)
@@ -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);

@@ -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);
		}
@@ -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 -------------------------*/
@@ -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;

@@ -602,15 +590,15 @@ 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;
@@ -618,7 +606,7 @@ int device_suspend_noirq(pm_message_t state)
	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;
@@ -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;

@@ -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) {
@@ -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;

@@ -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) {
@@ -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;

@@ -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)
{
+8 −8
Original line number Diff line number Diff line
@@ -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;
	}

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

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

	return 0;
}
@@ -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;
	}

@@ -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();
+5 −6
Original line number Diff line number Diff line
@@ -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);

@@ -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;
}
+7 −7
Original line number Diff line number Diff line
@@ -1448,17 +1448,17 @@ int kernel_kexec(void)
			goto Restore_console;
		}
		suspend_console();
		error = device_suspend(PMSG_FREEZE);
		error = dpm_suspend_start(PMSG_FREEZE);
		if (error)
			goto Resume_console;
		/* At this point, device_suspend() has been called,
		 * but *not* device_suspend_noirq(). We *must* call
		 * device_suspend_noirq() now.  Otherwise, drivers for
		/* At this point, dpm_suspend_start() has been called,
		 * but *not* dpm_suspend_noirq(). We *must* call
		 * dpm_suspend_noirq() now.  Otherwise, drivers for
		 * some devices (e.g. interrupt controllers) become
		 * desynchronized with the actual state of the
		 * hardware at resume time, and evil weirdness ensues.
		 */
		error = device_suspend_noirq(PMSG_FREEZE);
		error = dpm_suspend_noirq(PMSG_FREEZE);
		if (error)
			goto Resume_devices;
		error = disable_nonboot_cpus();
@@ -1486,9 +1486,9 @@ int kernel_kexec(void)
		local_irq_enable();
 Enable_cpus:
		enable_nonboot_cpus();
		device_resume_noirq(PMSG_RESTORE);
		dpm_resume_noirq(PMSG_RESTORE);
 Resume_devices:
		device_resume(PMSG_RESTORE);
		dpm_resume_end(PMSG_RESTORE);
 Resume_console:
		resume_console();
		thaw_processes();
Loading