Skip to content

Commit 0996584

Browse files
storulfrafaeljw
authored andcommitted
PM-runtime: Call pm_runtime_active|suspended_time() from sysfs
Avoid the open-coding of the accounted time acquisition in runtime_active|suspend_time_show() and make them call pm_runtime_active|suspended_time() instead. Note that this change also indirectly avoids holding dev->power.lock around the do_div() computation and the sprintf() call which is an additional improvement. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> [ rjw: Changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent fdc56c0 commit 0996584

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

drivers/base/power/runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags);
6464
* runtime_status field is updated, to account the time in the old state
6565
* correctly.
6666
*/
67-
void update_pm_runtime_accounting(struct device *dev)
67+
static void update_pm_runtime_accounting(struct device *dev)
6868
{
6969
u64 now, last, delta;
7070

drivers/base/power/sysfs.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev,
125125
struct device_attribute *attr, char *buf)
126126
{
127127
int ret;
128-
u64 tmp;
129-
spin_lock_irq(&dev->power.lock);
130-
update_pm_runtime_accounting(dev);
131-
tmp = dev->power.active_time;
128+
u64 tmp = pm_runtime_active_time(dev);
132129
do_div(tmp, NSEC_PER_MSEC);
133130
ret = sprintf(buf, "%llu\n", tmp);
134-
spin_unlock_irq(&dev->power.lock);
135131
return ret;
136132
}
137133

@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
141137
struct device_attribute *attr, char *buf)
142138
{
143139
int ret;
144-
u64 tmp;
145-
spin_lock_irq(&dev->power.lock);
146-
update_pm_runtime_accounting(dev);
147-
tmp = dev->power.suspended_time;
140+
u64 tmp = pm_runtime_suspended_time(dev);
148141
do_div(tmp, NSEC_PER_MSEC);
149142
ret = sprintf(buf, "%llu\n", tmp);
150-
spin_unlock_irq(&dev->power.lock);
151143
return ret;
152144
}
153145

include/linux/pm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ struct dev_pm_info {
643643
struct dev_pm_qos *qos;
644644
};
645645

646-
extern void update_pm_runtime_accounting(struct device *dev);
647646
extern int dev_pm_get_subsys_data(struct device *dev);
648647
extern void dev_pm_put_subsys_data(struct device *dev);
649648

0 commit comments

Comments
 (0)