2 * drivers/base/power/runtime.c - Handling dynamic device power management.
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
9 #include <linux/device.h>
13 static void runtime_resume(struct device * dev)
15 dev_dbg(dev, "resuming\n");
16 if (!dev->power.power_state.event)
18 if (!resume_device(dev))
19 dev->power.power_state = PMSG_ON;
24 * dpm_runtime_resume - Power one device back on.
27 * Bring one device back to the on state by first powering it
28 * on, then restoring state. We only operate on devices that aren't
30 * FIXME: We need to handle devices that are in an unknown state.
33 void dpm_runtime_resume(struct device * dev)
37 mutex_unlock(&dpm_mtx);
39 EXPORT_SYMBOL(dpm_runtime_resume);
43 * dpm_runtime_suspend - Put one device in low-power state.
45 * @state: State to enter.
48 int dpm_runtime_suspend(struct device * dev, pm_message_t state)
53 if (dev->power.power_state.event == state.event)
56 if (dev->power.power_state.event)
59 if (!(error = suspend_device(dev, state)))
60 dev->power.power_state = state;
62 mutex_unlock(&dpm_mtx);
65 EXPORT_SYMBOL(dpm_runtime_suspend);
70 * dpm_set_power_state - Update power_state field.
72 * @state: Power state device is in.
74 * This is an update mechanism for drivers to notify the core
75 * what power state a device is in. Device probing code may not
76 * always be able to tell, but we need accurate information to
79 void dpm_set_power_state(struct device * dev, pm_message_t state)
82 dev->power.power_state = state;
83 mutex_unlock(&dpm_mtx);