]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM-runtime: Call pm_runtime_active|suspended_time() from sysfs
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 5 Mar 2019 12:55:35 +0000 (13:55 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 7 Mar 2019 10:23:17 +0000 (11:23 +0100)
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>
drivers/base/power/runtime.c
drivers/base/power/sysfs.c
include/linux/pm.h

index 32f6bf076bd7cb27d017f03ea10f5beaccd60452..a2d22e3ecf3a63212eebe96d35bb93bca6955bc0 100644 (file)
@@ -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
  * correctly.
  */
-void update_pm_runtime_accounting(struct device *dev)
+static void update_pm_runtime_accounting(struct device *dev)
 {
        u64 now, last, delta;
 
index c6bf76124184c07ebdc0a10ea974b954f4f2489b..1226e441ddfede746d5652076e4396d41f3fa86f 100644 (file)
@@ -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;
 }
 
index 06f7ed8939286d6bf3ae75d334d369508dc47a71..66c19a65a514087f8d31752bc90711796cd24299 100644 (file)
@@ -643,7 +643,6 @@ struct dev_pm_info {
        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 void dev_pm_put_subsys_data(struct device *dev);