Skip to content

Commit fdc56c0

Browse files
storulfrafaeljw
authored andcommitted
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>
1 parent ef80068 commit fdc56c0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

drivers/base/power/power.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static inline void pm_runtime_early_init(struct device *dev)
2121
extern void pm_runtime_init(struct device *dev);
2222
extern void pm_runtime_reinit(struct device *dev);
2323
extern void pm_runtime_remove(struct device *dev);
24+
extern u64 pm_runtime_active_time(struct device *dev);
2425

2526
#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0)
2627
#define WAKE_IRQ_DEDICATED_MANAGED BIT(1)

drivers/base/power/runtime.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,30 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status)
9898
dev->power.runtime_status = status;
9999
}
100100

101-
u64 pm_runtime_suspended_time(struct device *dev)
101+
static u64 rpm_get_accounted_time(struct device *dev, bool suspended)
102102
{
103103
u64 time;
104104
unsigned long flags;
105105

106106
spin_lock_irqsave(&dev->power.lock, flags);
107107

108108
update_pm_runtime_accounting(dev);
109-
time = dev->power.suspended_time;
109+
time = suspended ? dev->power.suspended_time : dev->power.active_time;
110110

111111
spin_unlock_irqrestore(&dev->power.lock, flags);
112112

113113
return time;
114114
}
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+
}
115125
EXPORT_SYMBOL_GPL(pm_runtime_suspended_time);
116126

117127
/**

0 commit comments

Comments
 (0)