diff options
| author | Ulf Hansson <ulf.hansson@linaro.org> | 2019-03-05 07:55:26 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-03-07 05:23:17 -0500 |
| commit | fdc56c073270af2f4d223c96a5fff3048352fc03 (patch) | |
| tree | 255e77fb9ad72b3112e447b72b64c7b71b999fd0 /drivers | |
| parent | ef8006846a3a97d9d8bf49e63dba948d0d2dbbf0 (diff) | |
PM-runtime: Consolidate code to get active/suspended time
In a step to consolidate the code for fetching the PM-runtime
active/suspended time for a device, add a common function for that
and make the existing pm_runtime_suspended_time() call it.
Also add a corresponding pm_runtime_active_time() calling the new
common function.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[ rjw: Changelog, function rename ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/base/power/power.h | 1 | ||||
| -rw-r--r-- | drivers/base/power/runtime.c | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index c511def48b48..ec33fbdb919b 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
| @@ -21,6 +21,7 @@ static inline void pm_runtime_early_init(struct device *dev) | |||
| 21 | extern void pm_runtime_init(struct device *dev); | 21 | extern void pm_runtime_init(struct device *dev); |
| 22 | extern void pm_runtime_reinit(struct device *dev); | 22 | extern void pm_runtime_reinit(struct device *dev); |
| 23 | extern void pm_runtime_remove(struct device *dev); | 23 | extern void pm_runtime_remove(struct device *dev); |
| 24 | extern u64 pm_runtime_active_time(struct device *dev); | ||
| 24 | 25 | ||
| 25 | #define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0) | 26 | #define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0) |
| 26 | #define WAKE_IRQ_DEDICATED_MANAGED BIT(1) | 27 | #define WAKE_IRQ_DEDICATED_MANAGED BIT(1) |
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 78937c45278c..32f6bf076bd7 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
| @@ -98,7 +98,7 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status) | |||
| 98 | dev->power.runtime_status = status; | 98 | dev->power.runtime_status = status; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | u64 pm_runtime_suspended_time(struct device *dev) | 101 | static u64 rpm_get_accounted_time(struct device *dev, bool suspended) |
| 102 | { | 102 | { |
| 103 | u64 time; | 103 | u64 time; |
| 104 | unsigned long flags; | 104 | unsigned long flags; |
| @@ -106,12 +106,22 @@ u64 pm_runtime_suspended_time(struct device *dev) | |||
| 106 | spin_lock_irqsave(&dev->power.lock, flags); | 106 | spin_lock_irqsave(&dev->power.lock, flags); |
| 107 | 107 | ||
| 108 | update_pm_runtime_accounting(dev); | 108 | update_pm_runtime_accounting(dev); |
| 109 | time = dev->power.suspended_time; | 109 | time = suspended ? dev->power.suspended_time : dev->power.active_time; |
| 110 | 110 | ||
| 111 | spin_unlock_irqrestore(&dev->power.lock, flags); | 111 | spin_unlock_irqrestore(&dev->power.lock, flags); |
| 112 | 112 | ||
| 113 | return time; | 113 | return time; |
| 114 | } | 114 | } |
| 115 | |||
| 116 | u64 pm_runtime_active_time(struct device *dev) | ||
| 117 | { | ||
| 118 | return rpm_get_accounted_time(dev, false); | ||
| 119 | } | ||
| 120 | |||
| 121 | u64 pm_runtime_suspended_time(struct device *dev) | ||
| 122 | { | ||
| 123 | return rpm_get_accounted_time(dev, true); | ||
| 124 | } | ||
| 115 | EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); | 125 | EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); |
| 116 | 126 | ||
| 117 | /** | 127 | /** |
