aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2019-01-30 22:40:17 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-02-01 11:57:05 +0100
commitf800ea320c09fbc8bf15aecd5c05e8e6b27ae64e (patch)
tree27891d5eb9995a815dea208c6f7ea9e3d6501bde /drivers/base/power
parentMerge back earlier PM core material for v5.1. (diff)
downloadlinux-dev-f800ea320c09fbc8bf15aecd5c05e8e6b27ae64e.tar.xz
linux-dev-f800ea320c09fbc8bf15aecd5c05e8e6b27ae64e.zip
PM-runtime: Optimize pm_runtime_autosuspend_expiration()
pm_runtime_autosuspend_expiration calls ktime_get_mono_fast_ns() even when its returned value may be unused. Therefore get the current time later and remove gotos while there. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/runtime.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 4eaf166d7de1..1caa3944898f 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -145,24 +145,21 @@ static void pm_runtime_cancel_pending(struct device *dev)
u64 pm_runtime_autosuspend_expiration(struct device *dev)
{
int autosuspend_delay;
- u64 last_busy, expires = 0;
- u64 now = ktime_get_mono_fast_ns();
+ u64 expires;
if (!dev->power.use_autosuspend)
- goto out;
+ return 0;
autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
if (autosuspend_delay < 0)
- goto out;
-
- last_busy = READ_ONCE(dev->power.last_busy);
+ return 0;
- expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
- if (expires <= now)
- expires = 0; /* Already expired. */
+ expires = READ_ONCE(dev->power.last_busy);
+ expires += (u64)autosuspend_delay * NSEC_PER_MSEC;
+ if (expires > ktime_get_mono_fast_ns())
+ return expires; /* Expires in the future */
- out:
- return expires;
+ return 0;
}
EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);