提交 be49e346 编写于 作者: V Viresh Kumar 提交者: Rafael J. Wysocki

cpufreq: add new routine cpufreq_verify_within_cpu_limits()

Most of the users of cpufreq_verify_within_limits() calls it for
limiting with min/max from policy->cpuinfo. We can make that code
simple by introducing another routine which will do this for them
automatically.

This patch adds another routine cpufreq_verify_within_cpu_limits()
and updates others to use it.
Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
Acked-by: NDirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 0b981e70
...@@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy) ...@@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy)
if (policy->min < (fsb_pol_max * fid * 100)) if (policy->min < (fsb_pol_max * fid * 100))
policy->max = (fsb_pol_max + 1) * fid * 100; policy->max = (fsb_pol_max + 1) * fid * 100;
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy) ...@@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy)
if (policy->cpu) if (policy->cpu)
return -EINVAL; return -EINVAL;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000;
policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
......
...@@ -60,8 +60,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, ...@@ -60,8 +60,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n",
policy->min, policy->max, policy->cpu); policy->min, policy->max, policy->cpu);
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) {
if (freq == CPUFREQ_ENTRY_INVALID) if (freq == CPUFREQ_ENTRY_INVALID)
...@@ -77,8 +76,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, ...@@ -77,8 +76,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
if (!found) { if (!found) {
policy->max = next_larger; policy->max = next_larger;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
} }
pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", pr_debug("verification lead to (%u - %u kHz) for cpu %u\n",
......
...@@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) ...@@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy)
{ {
struct icst_vco vco; struct icst_vco vco;
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); vco = icst_hz_to_vco(&cclk_params, policy->max * 1000);
policy->max = icst_hz(&cclk_params, vco) / 1000; policy->max = icst_hz(&cclk_params, vco) / 1000;
...@@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) ...@@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy)
vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); vco = icst_hz_to_vco(&cclk_params, policy->min * 1000);
policy->min = icst_hz(&cclk_params, vco) / 1000; policy->min = icst_hz(&cclk_params, vco) / 1000;
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -611,9 +611,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) ...@@ -611,9 +611,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
static int intel_pstate_verify_policy(struct cpufreq_policy *policy) static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
{ {
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) &&
(policy->policy != CPUFREQ_POLICY_PERFORMANCE)) (policy->policy != CPUFREQ_POLICY_PERFORMANCE))
......
...@@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy) ...@@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy)
return -EINVAL; return -EINVAL;
policy->cpu = 0; policy->cpu = 0;
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) &&
(policy->policy != CPUFREQ_POLICY_PERFORMANCE)) (policy->policy != CPUFREQ_POLICY_PERFORMANCE))
......
...@@ -111,8 +111,7 @@ static struct pcc_cpu __percpu *pcc_cpu_info; ...@@ -111,8 +111,7 @@ static struct pcc_cpu __percpu *pcc_cpu_info;
static int pcc_cpufreq_verify(struct cpufreq_policy *policy) static int pcc_cpufreq_verify(struct cpufreq_policy *policy)
{ {
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy) ...@@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy)
if (freq_table) if (freq_table)
return cpufreq_frequency_table_verify(policy, freq_table); return cpufreq_frequency_table_verify(policy, freq_table);
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000;
policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -29,9 +29,7 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy) ...@@ -29,9 +29,7 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy)
if (policy->cpu) if (policy->cpu)
return -EINVAL; return -EINVAL;
cpufreq_verify_within_limits(policy, cpufreq_verify_within_cpu_limits(policy);
policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
return 0; return 0;
} }
......
...@@ -242,6 +242,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, ...@@ -242,6 +242,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
return; return;
} }
static inline void
cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
{
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
policy->cpuinfo.max_freq);
}
/********************************************************************* /*********************************************************************
* CPUFREQ NOTIFIER INTERFACE * * CPUFREQ NOTIFIER INTERFACE *
*********************************************************************/ *********************************************************************/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册