diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-08-05 19:44:28 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-09-03 19:36:03 -0400 |
commit | e91c11b1a7f876c6f056d872eb210734150a1795 (patch) | |
tree | 7f988ffa41a4a4f04aaad939d1f8b9baf1766d9e /drivers/base | |
parent | cc7ad4564b1097c916834dc919678867631e7676 (diff) |
PM: Reorganize device PM initialization
Make the device power management initialization more straightforward
by moving the initialization of common (i.e. used by both runtime PM
and system suspend) fields to a separate routine.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/main.c | 7 | ||||
-rw-r--r-- | drivers/base/power/power.h | 22 |
2 files changed, 17 insertions, 12 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0113adc310dc..7bd1fe400549 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -57,20 +57,17 @@ static pm_message_t pm_transition; | |||
57 | static int async_error; | 57 | static int async_error; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * device_pm_init - Initialize the PM-related part of a device object. | 60 | * device_pm_sleep_init - Initialize system suspend-related device fields. |
61 | * @dev: Device object being initialized. | 61 | * @dev: Device object being initialized. |
62 | */ | 62 | */ |
63 | void device_pm_init(struct device *dev) | 63 | void device_pm_sleep_init(struct device *dev) |
64 | { | 64 | { |
65 | dev->power.is_prepared = false; | 65 | dev->power.is_prepared = false; |
66 | dev->power.is_suspended = false; | 66 | dev->power.is_suspended = false; |
67 | init_completion(&dev->power.completion); | 67 | init_completion(&dev->power.completion); |
68 | complete_all(&dev->power.completion); | 68 | complete_all(&dev->power.completion); |
69 | dev->power.wakeup = NULL; | 69 | dev->power.wakeup = NULL; |
70 | spin_lock_init(&dev->power.lock); | ||
71 | pm_runtime_init(dev); | ||
72 | INIT_LIST_HEAD(&dev->power.entry); | 70 | INIT_LIST_HEAD(&dev->power.entry); |
73 | dev->power.power_state = PMSG_INVALID; | ||
74 | } | 71 | } |
75 | 72 | ||
76 | /** | 73 | /** |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index eeb4bff9505c..8a0dcc7f98f9 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -1,5 +1,11 @@ | |||
1 | #include <linux/pm_qos.h> | 1 | #include <linux/pm_qos.h> |
2 | 2 | ||
3 | static inline void device_pm_init_common(struct device *dev) | ||
4 | { | ||
5 | spin_lock_init(&dev->power.lock); | ||
6 | dev->power.power_state = PMSG_INVALID; | ||
7 | } | ||
8 | |||
3 | #ifdef CONFIG_PM_RUNTIME | 9 | #ifdef CONFIG_PM_RUNTIME |
4 | 10 | ||
5 | extern void pm_runtime_init(struct device *dev); | 11 | extern void pm_runtime_init(struct device *dev); |
@@ -25,7 +31,7 @@ static inline struct device *to_device(struct list_head *entry) | |||
25 | return container_of(entry, struct device, power.entry); | 31 | return container_of(entry, struct device, power.entry); |
26 | } | 32 | } |
27 | 33 | ||
28 | extern void device_pm_init(struct device *dev); | 34 | extern void device_pm_sleep_init(struct device *dev); |
29 | extern void device_pm_add(struct device *); | 35 | extern void device_pm_add(struct device *); |
30 | extern void device_pm_remove(struct device *); | 36 | extern void device_pm_remove(struct device *); |
31 | extern void device_pm_move_before(struct device *, struct device *); | 37 | extern void device_pm_move_before(struct device *, struct device *); |
@@ -34,12 +40,7 @@ extern void device_pm_move_last(struct device *); | |||
34 | 40 | ||
35 | #else /* !CONFIG_PM_SLEEP */ | 41 | #else /* !CONFIG_PM_SLEEP */ |
36 | 42 | ||
37 | static inline void device_pm_init(struct device *dev) | 43 | static inline void device_pm_sleep_init(struct device *dev) {} |
38 | { | ||
39 | spin_lock_init(&dev->power.lock); | ||
40 | dev->power.power_state = PMSG_INVALID; | ||
41 | pm_runtime_init(dev); | ||
42 | } | ||
43 | 44 | ||
44 | static inline void device_pm_add(struct device *dev) | 45 | static inline void device_pm_add(struct device *dev) |
45 | { | 46 | { |
@@ -60,6 +61,13 @@ static inline void device_pm_move_last(struct device *dev) {} | |||
60 | 61 | ||
61 | #endif /* !CONFIG_PM_SLEEP */ | 62 | #endif /* !CONFIG_PM_SLEEP */ |
62 | 63 | ||
64 | static inline void device_pm_init(struct device *dev) | ||
65 | { | ||
66 | device_pm_init_common(dev); | ||
67 | device_pm_sleep_init(dev); | ||
68 | pm_runtime_init(dev); | ||
69 | } | ||
70 | |||
63 | #ifdef CONFIG_PM | 71 | #ifdef CONFIG_PM |
64 | 72 | ||
65 | /* | 73 | /* |