Commit 0996584b authored by Ulf Hansson's avatar Ulf Hansson Committed by Rafael J. Wysocki

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: default avatarUlf Hansson <ulf.hansson@linaro.org>
[ rjw: Changelog ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent fdc56c07
...@@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags); ...@@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags);
* runtime_status field is updated, to account the time in the old state * runtime_status field is updated, to account the time in the old state
* correctly. * correctly.
*/ */
void update_pm_runtime_accounting(struct device *dev) static void update_pm_runtime_accounting(struct device *dev)
{ {
u64 now, last, delta; u64 now, last, delta;
......
...@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev, ...@@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int ret; int ret;
u64 tmp; u64 tmp = pm_runtime_active_time(dev);
spin_lock_irq(&dev->power.lock);
update_pm_runtime_accounting(dev);
tmp = dev->power.active_time;
do_div(tmp, NSEC_PER_MSEC); do_div(tmp, NSEC_PER_MSEC);
ret = sprintf(buf, "%llu\n", tmp); ret = sprintf(buf, "%llu\n", tmp);
spin_unlock_irq(&dev->power.lock);
return ret; return ret;
} }
...@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev, ...@@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int ret; int ret;
u64 tmp; u64 tmp = pm_runtime_suspended_time(dev);
spin_lock_irq(&dev->power.lock);
update_pm_runtime_accounting(dev);
tmp = dev->power.suspended_time;
do_div(tmp, NSEC_PER_MSEC); do_div(tmp, NSEC_PER_MSEC);
ret = sprintf(buf, "%llu\n", tmp); ret = sprintf(buf, "%llu\n", tmp);
spin_unlock_irq(&dev->power.lock);
return ret; return ret;
} }
......
...@@ -643,7 +643,6 @@ struct dev_pm_info { ...@@ -643,7 +643,6 @@ struct dev_pm_info {
struct dev_pm_qos *qos; struct dev_pm_qos *qos;
}; };
extern void update_pm_runtime_accounting(struct device *dev);
extern int dev_pm_get_subsys_data(struct device *dev); extern int dev_pm_get_subsys_data(struct device *dev);
extern void dev_pm_put_subsys_data(struct device *dev); extern void dev_pm_put_subsys_data(struct device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment