Skip to content

Commit

Permalink
thermal: cpu_cooling: initialize 'cpufreq_val' on registration
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Viresh Kumar authored and Eduardo Valentin committed Dec 8, 2014
1 parent 730abe0 commit 7adb635
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/thermal/cpu_cooling.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7adb635

Please sign in to comment.