aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal/cpu_cooling.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-12-04 09:41:59 +0530
committerKevin Hilman <khilman@linaro.org>2015-06-05 15:42:19 -0700
commit9e31ee49bbcf1fb2e11ff191816fd3508988da21 (patch)
tree9c94133a83a26d3230b63c88420e5de5070121be /drivers/thermal/cpu_cooling.c
parent353ec245f2bf5dd2cda3a72e20a8f1405cd43850 (diff)
thermal: cpu_cooling: initialize 'cpufreq_val' on registration
There is no point checking for validity of 'cpufreq_val' from cpufreq_thermal_notifier() every time the routine is called. Its guaranteed to be 0 on the first call but will be valid otherwise. Lets update it once while the device registers. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com> (cherry picked from commit 7adb635b3cd790e4e0d7e9d0b3dd30574ae36596) Signed-off-by: Kevin Hilman <khilman@linaro.org>
Diffstat (limited to 'drivers/thermal/cpu_cooling.c')
-rw-r--r--drivers/thermal/cpu_cooling.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 491d90aeeebe..86bcf8dc14d3 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -316,11 +316,6 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
&cpufreq_dev->allowed_cpus))
continue;
- if (!cpufreq_dev->cpufreq_val)
- cpufreq_dev->cpufreq_val = get_cpu_frequency(
- cpumask_any(&cpufreq_dev->allowed_cpus),
- cpufreq_dev->cpufreq_state);
-
max_freq = cpufreq_dev->cpufreq_val;
if (policy->max != max_freq)
@@ -444,6 +439,13 @@ __cpufreq_cooling_register(struct device_node *np,
if (!cpufreq_dev)
return ERR_PTR(-ENOMEM);
+ cpufreq_dev->cpufreq_val = get_cpu_frequency(cpumask_any(clip_cpus), 0);
+ if (!cpufreq_dev->cpufreq_val) {
+ pr_err("%s: Failed to get frequency", __func__);
+ cool_dev = ERR_PTR(-EINVAL);
+ goto free_cdev;
+ }
+
cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);