summaryrefslogtreecommitdiff
path: root/drivers/base/power/power.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-06 01:45:11 +0200
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-04 01:36:03 +0200
commitbed2b42d9f0b411f384c5619870ab0fea5dd116b (patch)
treeabdfe3a877b5751411ba10d6bf1a57040c56bf73 /drivers/base/power/power.h
parente91c11b1a7f876c6f056d872eb210734150a1795 (diff)
PM / Runtime: Allow helpers to be called by early platform drivers
Runtime PM helper functions, like pm_runtime_get_sync(), cannot be called by early platform device drivers, because the devices' power management locks are not initialized at that time. This is quite inconvenient, so modify early_platform_add_devices() to initialize the devices power management locks as appropriate and make sure that they won't be initialized more than once if an early platform device is going to be used as a regular one later. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power/power.h')
-rw-r--r--drivers/base/power/power.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 8a0dcc7f98f9..0dbfdf4419af 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -2,17 +2,31 @@
static inline void device_pm_init_common(struct device *dev)
{
- spin_lock_init(&dev->power.lock);
- dev->power.power_state = PMSG_INVALID;
+ if (!dev->power.early_init) {
+ spin_lock_init(&dev->power.lock);
+ dev->power.power_state = PMSG_INVALID;
+ dev->power.early_init = true;
+ }
}
#ifdef CONFIG_PM_RUNTIME
+static inline void pm_runtime_early_init(struct device *dev)
+{
+ dev->power.disable_depth = 1;
+ device_pm_init_common(dev);
+}
+
extern void pm_runtime_init(struct device *dev);
extern void pm_runtime_remove(struct device *dev);
#else /* !CONFIG_PM_RUNTIME */
+static inline void pm_runtime_early_init(struct device *dev)
+{
+ device_pm_init_common(dev);
+}
+
static inline void pm_runtime_init(struct device *dev) {}
static inline void pm_runtime_remove(struct device *dev) {}