diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2012-10-30 20:28:21 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:33:09 -0500 |
commit | 7249924e537816368c4a35afd97ab311f75a6368 (patch) | |
tree | a332ffc88c23988b4add2bab60705357a230b705 | |
parent | 5a1c022850ea5d64c2997bf9b89f5ae112d5ee4d (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>
-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 28dc134cec36..2f5ac2dcfda6 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1470 | unsigned int relation) | 1470 | unsigned int relation) |
1471 | { | 1471 | { |
1472 | int retval = -EINVAL; | 1472 | int retval = -EINVAL; |
1473 | unsigned int old_target_freq = target_freq; | ||
1473 | 1474 | ||
1474 | if (cpufreq_disabled()) | 1475 | if (cpufreq_disabled()) |
1475 | return -ENODEV; | 1476 | return -ENODEV; |
1476 | 1477 | ||
1477 | pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, | 1478 | /* Make sure that target_freq is within supported range */ |
1478 | target_freq, relation); | 1479 | if (target_freq > policy->max) |
1480 | target_freq = policy->max; | ||
1481 | if (target_freq < policy->min) | ||
1482 | target_freq = policy->min; | ||
1483 | |||
1484 | pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", | ||
1485 | policy->cpu, target_freq, relation, old_target_freq); | ||
1479 | 1486 | ||
1480 | if (target_freq == policy->cur) | 1487 | if (target_freq == policy->cur) |
1481 | return 0; | 1488 | return 0; |