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>
This commit is contained in:
Родитель
1cc9c59569
Коммит
f800ea320c
|
@ -145,24 +145,21 @@ static void pm_runtime_cancel_pending(struct device *dev)
|
||||||
u64 pm_runtime_autosuspend_expiration(struct device *dev)
|
u64 pm_runtime_autosuspend_expiration(struct device *dev)
|
||||||
{
|
{
|
||||||
int autosuspend_delay;
|
int autosuspend_delay;
|
||||||
u64 last_busy, expires = 0;
|
u64 expires;
|
||||||
u64 now = ktime_get_mono_fast_ns();
|
|
||||||
|
|
||||||
if (!dev->power.use_autosuspend)
|
if (!dev->power.use_autosuspend)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
|
autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
|
||||||
if (autosuspend_delay < 0)
|
if (autosuspend_delay < 0)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
last_busy = READ_ONCE(dev->power.last_busy);
|
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 */
|
||||||
|
|
||||||
expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
|
return 0;
|
||||||
if (expires <= now)
|
|
||||||
expires = 0; /* Already expired. */
|
|
||||||
|
|
||||||
out:
|
|
||||||
return expires;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
|
EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче