From 763cf29b05389d3fdfd3f026e87dc8e8024182fc Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Tue, 17 Dec 2019 12:09:07 +0530 Subject: [PATCH] cpuidle: lpm-levels: Reorganize code to calculate next wakeup Add new inline function to calculate next wakeup. Change-Id: Iaa17563597cf794966cc0e89159a1d8b257fa6dd Signed-off-by: Maulik Shah --- drivers/cpuidle/lpm-levels.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c index e7801c23d13a..fd084e195a89 100644 --- a/drivers/cpuidle/lpm-levels.c +++ b/drivers/cpuidle/lpm-levels.c @@ -636,6 +636,21 @@ out: return false; } +static void calculate_next_wakeup(uint32_t *next_wakeup_us, + uint32_t next_event_us, + uint32_t lvl_latency_us, + s64 sleep_us) +{ + if (!next_event_us) + return; + + if (next_event_us < lvl_latency_us) + return; + + if (next_event_us < sleep_us) + *next_wakeup_us = next_event_us - lvl_latency_us; +} + static int cpu_power_select(struct cpuidle_device *dev, struct lpm_cpu *cpu) { @@ -672,13 +687,8 @@ static int cpu_power_select(struct cpuidle_device *dev, if (latency_us < lvl_latency_us) break; - if (next_event_us) { - if (next_event_us < lvl_latency_us) - break; - - if (next_event_us < sleep_us) - next_wakeup_us = next_event_us - lvl_latency_us; - } + calculate_next_wakeup(&next_wakeup_us, next_event_us, + lvl_latency_us, sleep_us); if (!i && !cpu_isolated(dev->cpu)) { /*