diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-07-21 17:39:26 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-07-21 17:45:17 -0400 |
commit | abe8bd024e7ac21ad21348c0fea09aefb4e469c7 (patch) | |
tree | f2ded02076e86e7cd8fce195c08d2721f4a7e495 /drivers/cpufreq/cpufreq.c | |
parent | 5b6667c76d39e325d3c05b1f7e40f8a0e4bd6681 (diff) |
cpufreq: Disallow ->resolve_freq() for drivers providing ->target_index()
The handlers provided by cpufreq core are sufficient for resolving the
frequency for drivers providing ->target_index(), as the core already
has the frequency table and so ->resolve_freq() isn't required for such
platforms.
This patch disallows drivers with ->target_index() callback to use the
->resolve_freq() callback.
Also, it fixes a potential kernel crash for drivers providing ->target()
but no ->resolve_freq().
Fixes: e3c062360870 "cpufreq: add cpufreq_driver_resolve_freq()"
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b696baeb249d..3ef9be3965ff 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -507,12 +507,20 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, | |||
507 | { | 507 | { |
508 | target_freq = clamp_val(target_freq, policy->min, policy->max); | 508 | target_freq = clamp_val(target_freq, policy->min, policy->max); |
509 | policy->cached_target_freq = target_freq; | 509 | policy->cached_target_freq = target_freq; |
510 | |||
511 | if (cpufreq_driver->target_index) { | ||
512 | int idx; | ||
513 | |||
514 | idx = cpufreq_frequency_table_target(policy, target_freq, | ||
515 | CPUFREQ_RELATION_L); | ||
516 | policy->cached_resolved_idx = idx; | ||
517 | return policy->freq_table[idx].frequency; | ||
518 | } | ||
519 | |||
510 | if (cpufreq_driver->resolve_freq) | 520 | if (cpufreq_driver->resolve_freq) |
511 | return cpufreq_driver->resolve_freq(policy, target_freq); | 521 | return cpufreq_driver->resolve_freq(policy, target_freq); |
512 | policy->cached_resolved_idx = | 522 | |
513 | cpufreq_frequency_table_target(policy, target_freq, | 523 | return target_freq; |
514 | CPUFREQ_RELATION_L); | ||
515 | return policy->freq_table[policy->cached_resolved_idx].frequency; | ||
516 | } | 524 | } |
517 | 525 | ||
518 | /********************************************************************* | 526 | /********************************************************************* |