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>

authored by Alan Stern and committed by Rafael J. Wysocki 4769373c 69d44ffb

+38 -39
+38 -39
drivers/base/power/runtime.c
··· 15 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 56 * pm_runtime_deactivate_timer - Deactivate given device's suspend timer. 19 57 * @dev: Device to handle. 20 58 */ ··· 160 122 return retval; 161 123 } 162 124 EXPORT_SYMBOL_GPL(pm_runtime_idle); 163 - 164 - 165 - /** 166 - * update_pm_runtime_accounting - Update the time accounting of power states 167 - * @dev: Device to update the accounting for 168 - * 169 - * In order to be able to have time accounting of the various power states 170 - * (as used by programs such as PowerTOP to show the effectiveness of runtime 171 - * PM), we need to track the time spent in each state. 172 - * update_pm_runtime_accounting must be called each time before the 173 - * runtime_status field is updated, to account the time in the old state 174 - * correctly. 175 - */ 176 - void update_pm_runtime_accounting(struct device *dev) 177 - { 178 - unsigned long now = jiffies; 179 - int delta; 180 - 181 - delta = now - dev->power.accounting_timestamp; 182 - 183 - if (delta < 0) 184 - delta = 0; 185 - 186 - dev->power.accounting_timestamp = now; 187 - 188 - if (dev->power.disable_depth > 0) 189 - return; 190 - 191 - if (dev->power.runtime_status == RPM_SUSPENDED) 192 - dev->power.suspended_jiffies += delta; 193 - else 194 - dev->power.active_jiffies += delta; 195 - } 196 - 197 - static void __update_runtime_status(struct device *dev, enum rpm_status status) 198 - { 199 - update_pm_runtime_accounting(dev); 200 - dev->power.runtime_status = status; 201 - } 202 125 203 126 /** 204 127 * __pm_runtime_suspend - Carry out run-time suspend of given device.