diff options
| author | Viresh Kumar <viresh.kumar@linaro.org> | 2012-10-31 01:28:21 +0100 |
|---|---|---|
| committer | Suraj Das <surajdazz@gmail.com> | 2017-04-03 22:40:20 +0530 |
| commit | 8400436f121890b40e86dfdc45c1a7df34e84855 (patch) | |
| tree | 709cd141cb613b221ba57df665f111ffa66af8b1 | |
| parent | b997ff52421ba4987ce9838b80bab4b3444f61b0 (diff) | |
cpufreq: Make sure target freq is within limits
__cpufreq_driver_target() must not pass target frequency beyond the
limits of current policy.
Today most of cpufreq platform drivers are doing this check in their
target routines. Why not move it to __cpufreq_driver_target()?
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
| -rw-r--r-- | drivers/cpufreq/cpufreq.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1e8153decee..e8c2a016ef7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1548,12 +1548,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { int retval = -EINVAL; + unsigned int old_target_freq = target_freq; if (cpufreq_disabled()) return -ENODEV; - pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, - target_freq, relation); + /* Make sure that target_freq is within supported range */ + if (target_freq > policy->max) + target_freq = policy->max; + if (target_freq < policy->min) + target_freq = policy->min; + + pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", + policy->cpu, target_freq, relation, old_target_freq); if (target_freq == policy->cur) return 0; |
