diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-09-25 17:34:46 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2010-10-16 19:57:44 -0400 |
commit | 4769373ca2c8d0b999749a070c48fd8648888831 (patch) | |
tree | 62ec8eed1390d3fd9f9eb6cf979037ca316bf625 /drivers/base | |
parent | 69d44ffbd772bede8c2a6d182e6e14f94826520b (diff) |
PM / Runtime: Move code in drivers/base/power/runtime.c
This patch (as1421) moves the PM runtime accounting subroutines up to
the beginning of runtime.c, taking them out of the middle of the
functions that do the actual work. No operational changes.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/runtime.c | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index e9520ad2d716..ec08f1ae63f1 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
@@ -15,6 +15,44 @@ static int __pm_request_idle(struct device *dev); | |||
15 | static int __pm_request_resume(struct device *dev); | 15 | static int __pm_request_resume(struct device *dev); |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * update_pm_runtime_accounting - Update the time accounting of power states | ||
19 | * @dev: Device to update the accounting for | ||
20 | * | ||
21 | * In order to be able to have time accounting of the various power states | ||
22 | * (as used by programs such as PowerTOP to show the effectiveness of runtime | ||
23 | * PM), we need to track the time spent in each state. | ||
24 | * update_pm_runtime_accounting must be called each time before the | ||
25 | * runtime_status field is updated, to account the time in the old state | ||
26 | * correctly. | ||
27 | */ | ||
28 | void update_pm_runtime_accounting(struct device *dev) | ||
29 | { | ||
30 | unsigned long now = jiffies; | ||
31 | int delta; | ||
32 | |||
33 | delta = now - dev->power.accounting_timestamp; | ||
34 | |||
35 | if (delta < 0) | ||
36 | delta = 0; | ||
37 | |||
38 | dev->power.accounting_timestamp = now; | ||
39 | |||
40 | if (dev->power.disable_depth > 0) | ||
41 | return; | ||
42 | |||
43 | if (dev->power.runtime_status == RPM_SUSPENDED) | ||
44 | dev->power.suspended_jiffies += delta; | ||
45 | else | ||
46 | dev->power.active_jiffies += delta; | ||
47 | } | ||
48 | |||
49 | static void __update_runtime_status(struct device *dev, enum rpm_status status) | ||
50 | { | ||
51 | update_pm_runtime_accounting(dev); | ||
52 | dev->power.runtime_status = status; | ||
53 | } | ||
54 | |||
55 | /** | ||
18 | * pm_runtime_deactivate_timer - Deactivate given device's suspend timer. | 56 | * pm_runtime_deactivate_timer - Deactivate given device's suspend timer. |
19 | * @dev: Device to handle. | 57 | * @dev: Device to handle. |
20 | */ | 58 | */ |
@@ -123,45 +161,6 @@ int pm_runtime_idle(struct device *dev) | |||
123 | } | 161 | } |
124 | EXPORT_SYMBOL_GPL(pm_runtime_idle); | 162 | EXPORT_SYMBOL_GPL(pm_runtime_idle); |
125 | 163 | ||
126 | |||
127 | /** | ||
128 | * update_pm_runtime_accounting - Update the time accounting of power states | ||
129 | * @dev: Device to update the accounting for | ||
130 | * | ||
131 | * In order to be able to have time accounting of the various power states | ||
132 | * (as used by programs such as PowerTOP to show the effectiveness of runtime | ||
133 | * PM), we need to track the time spent in each state. | ||
134 | * update_pm_runtime_accounting must be called each time before the | ||
135 | * runtime_status field is updated, to account the time in the old state | ||
136 | * correctly. | ||
137 | */ | ||
138 | void update_pm_runtime_accounting(struct device *dev) | ||
139 | { | ||
140 | unsigned long now = jiffies; | ||
141 | int delta; | ||
142 | |||
143 | delta = now - dev->power.accounting_timestamp; | ||
144 | |||
145 | if (delta < 0) | ||
146 | delta = 0; | ||
147 | |||
148 | dev->power.accounting_timestamp = now; | ||
149 | |||
150 | if (dev->power.disable_depth > 0) | ||
151 | return; | ||
152 | |||
153 | if (dev->power.runtime_status == RPM_SUSPENDED) | ||
154 | dev->power.suspended_jiffies += delta; | ||
155 | else | ||
156 | dev->power.active_jiffies += delta; | ||
157 | } | ||
158 | |||
159 | static void __update_runtime_status(struct device *dev, enum rpm_status status) | ||
160 | { | ||
161 | update_pm_runtime_accounting(dev); | ||
162 | dev->power.runtime_status = status; | ||
163 | } | ||
164 | |||
165 | /** | 164 | /** |
166 | * __pm_runtime_suspend - Carry out run-time suspend of given device. | 165 | * __pm_runtime_suspend - Carry out run-time suspend of given device. |
167 | * @dev: Device to suspend. | 166 | * @dev: Device to suspend. |