[COMMON] thermal: cpu_cooling: Ignore calcuate power
authorHyeonseong Gil <hs.gil@samsung.com>
Wed, 21 Mar 2018 04:53:59 +0000 (13:53 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:22:27 +0000 (17:22 +0900)
When none of cpus are online in policy,
do not need to calculate the power

Change-Id: If7e0fb21c804260bc0cb3df71a03ee09db235261
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/cpu_cooling.c

index ed3eac58651de7753cf5601cccdcdec5b4afba5b..066bb6926e89cbf88cbd0f4396aa8624e3000382 100644 (file)
@@ -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)