From d282e54da14d5b64bf4b8bba1c193a67acd39cc2 Mon Sep 17 00:00:00 2001 From: Hyeonseong Gil Date: Wed, 21 Mar 2018 13:53:59 +0900 Subject: [PATCH] [COMMON] thermal: cpu_cooling: Ignore calcuate power When none of cpus are online in policy, do not need to calculate the power Change-Id: If7e0fb21c804260bc0cb3df71a03ee09db235261 Signed-off-by: Hyeonseong Gil --- drivers/thermal/cpu_cooling.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index ed3eac58651d..066bb6926e89 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -496,7 +496,9 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_cdev, *power = 0; dev = get_cpu_device(policy->cpu); - WARN_ON(!dev); + + if (!dev) + return 0; opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true); if (IS_ERR(opp)) { @@ -789,6 +791,10 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, cpu = cpumask_any_and(policy->related_cpus, cpu_online_mask); + /* None of our cpus are online */ + if (cpu >= nr_cpu_ids) + return -ENODEV; + cur_freq = cpufreq_quick_get(policy->cpu); ret = get_static_power(cpufreq_cdev, tz, cur_freq, &static_power); if (ret) -- 2.20.1