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>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
fdc56c0732
commit
0996584b30
@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int ret;
|
||||
u64 tmp;
|
||||
spin_lock_irq(&dev->power.lock);
|
||||
update_pm_runtime_accounting(dev);
|
||||
tmp = dev->power.active_time;
|
||||
u64 tmp = pm_runtime_active_time(dev);
|
||||
do_div(tmp, NSEC_PER_MSEC);
|
||||
ret = sprintf(buf, "%llu\n", tmp);
|
||||
spin_unlock_irq(&dev->power.lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int ret;
|
||||
u64 tmp;
|
||||
spin_lock_irq(&dev->power.lock);
|
||||
update_pm_runtime_accounting(dev);
|
||||
tmp = dev->power.suspended_time;
|
||||
u64 tmp = pm_runtime_suspended_time(dev);
|
||||
do_div(tmp, NSEC_PER_MSEC);
|
||||
ret = sprintf(buf, "%llu\n", tmp);
|
||||
spin_unlock_irq(&dev->power.lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user