diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-10-02 04:43:19 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-10-15 18:50:23 -0400 |
commit | be49e3465f222b4b796be8a21d14afbfd8f5d20f (patch) | |
tree | e1ef5d9cb453bb3c7f073a4d209d2b63d980aec3 /drivers/cpufreq | |
parent | 0b981e70748861a3e10ea2e2a689bdcee3e15085 (diff) |
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: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq-nforce2.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/davinci-cpufreq.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/freq_table.c | 6 | ||||
-rw-r--r-- | drivers/cpufreq/integrator-cpufreq.c | 9 | ||||
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/longrun.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/pcc-cpufreq.c | 3 | ||||
-rw-r--r-- | drivers/cpufreq/sh-cpufreq.c | 7 | ||||
-rw-r--r-- | drivers/cpufreq/unicore2-cpufreq.c | 4 |
9 files changed, 12 insertions, 33 deletions
diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index b83d45f68574..56c964c16a66 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c | |||
@@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy) | |||
303 | if (policy->min < (fsb_pol_max * fid * 100)) | 303 | if (policy->min < (fsb_pol_max * fid * 100)) |
304 | policy->max = (fsb_pol_max + 1) * fid * 100; | 304 | policy->max = (fsb_pol_max + 1) * fid * 100; |
305 | 305 | ||
306 | cpufreq_verify_within_limits(policy, | 306 | cpufreq_verify_within_cpu_limits(policy); |
307 | policy->cpuinfo.min_freq, | ||
308 | policy->cpuinfo.max_freq); | ||
309 | return 0; | 307 | return 0; |
310 | } | 308 | } |
311 | 309 | ||
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c index f67196e21fc9..ba03e6f91d47 100644 --- a/drivers/cpufreq/davinci-cpufreq.c +++ b/drivers/cpufreq/davinci-cpufreq.c | |||
@@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy) | |||
50 | if (policy->cpu) | 50 | if (policy->cpu) |
51 | return -EINVAL; | 51 | return -EINVAL; |
52 | 52 | ||
53 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 53 | cpufreq_verify_within_cpu_limits(policy); |
54 | policy->cpuinfo.max_freq); | ||
55 | |||
56 | policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; | 54 | policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; |
57 | policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; | 55 | policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; |
58 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 56 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 10f3cfb6b513..b9336edb9bd6 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -60,8 +60,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
60 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", | 60 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", |
61 | policy->min, policy->max, policy->cpu); | 61 | policy->min, policy->max, policy->cpu); |
62 | 62 | ||
63 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 63 | cpufreq_verify_within_cpu_limits(policy); |
64 | policy->cpuinfo.max_freq); | ||
65 | 64 | ||
66 | for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { | 65 | for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { |
67 | if (freq == CPUFREQ_ENTRY_INVALID) | 66 | if (freq == CPUFREQ_ENTRY_INVALID) |
@@ -77,8 +76,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
77 | 76 | ||
78 | if (!found) { | 77 | if (!found) { |
79 | policy->max = next_larger; | 78 | policy->max = next_larger; |
80 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 79 | cpufreq_verify_within_cpu_limits(policy); |
81 | policy->cpuinfo.max_freq); | ||
82 | } | 80 | } |
83 | 81 | ||
84 | pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", | 82 | pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", |
diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c index f7c99df0880b..8152a9bb7e2c 100644 --- a/drivers/cpufreq/integrator-cpufreq.c +++ b/drivers/cpufreq/integrator-cpufreq.c | |||
@@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) | |||
59 | { | 59 | { |
60 | struct icst_vco vco; | 60 | struct icst_vco vco; |
61 | 61 | ||
62 | cpufreq_verify_within_limits(policy, | 62 | cpufreq_verify_within_cpu_limits(policy); |
63 | policy->cpuinfo.min_freq, | ||
64 | policy->cpuinfo.max_freq); | ||
65 | 63 | ||
66 | vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); | 64 | vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); |
67 | policy->max = icst_hz(&cclk_params, vco) / 1000; | 65 | policy->max = icst_hz(&cclk_params, vco) / 1000; |
@@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) | |||
69 | vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); | 67 | vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); |
70 | policy->min = icst_hz(&cclk_params, vco) / 1000; | 68 | policy->min = icst_hz(&cclk_params, vco) / 1000; |
71 | 69 | ||
72 | cpufreq_verify_within_limits(policy, | 70 | cpufreq_verify_within_cpu_limits(policy); |
73 | policy->cpuinfo.min_freq, | ||
74 | policy->cpuinfo.max_freq); | ||
75 | |||
76 | return 0; | 71 | return 0; |
77 | } | 72 | } |
78 | 73 | ||
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 9733f29ed148..a02bd77cbfe8 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -611,9 +611,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
611 | 611 | ||
612 | static int intel_pstate_verify_policy(struct cpufreq_policy *policy) | 612 | static int intel_pstate_verify_policy(struct cpufreq_policy *policy) |
613 | { | 613 | { |
614 | cpufreq_verify_within_limits(policy, | 614 | cpufreq_verify_within_cpu_limits(policy); |
615 | policy->cpuinfo.min_freq, | ||
616 | policy->cpuinfo.max_freq); | ||
617 | 615 | ||
618 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && | 616 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && |
619 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) | 617 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) |
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c index 5aa031612d53..074971b12635 100644 --- a/drivers/cpufreq/longrun.c +++ b/drivers/cpufreq/longrun.c | |||
@@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy) | |||
129 | return -EINVAL; | 129 | return -EINVAL; |
130 | 130 | ||
131 | policy->cpu = 0; | 131 | policy->cpu = 0; |
132 | cpufreq_verify_within_limits(policy, | 132 | cpufreq_verify_within_cpu_limits(policy); |
133 | policy->cpuinfo.min_freq, | ||
134 | policy->cpuinfo.max_freq); | ||
135 | 133 | ||
136 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && | 134 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && |
137 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) | 135 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) |
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index d81c4e5ea0ad..78787e965e0b 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
@@ -111,8 +111,7 @@ static struct pcc_cpu __percpu *pcc_cpu_info; | |||
111 | 111 | ||
112 | static int pcc_cpufreq_verify(struct cpufreq_policy *policy) | 112 | static int pcc_cpufreq_verify(struct cpufreq_policy *policy) |
113 | { | 113 | { |
114 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 114 | cpufreq_verify_within_cpu_limits(policy); |
115 | policy->cpuinfo.max_freq); | ||
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
118 | 117 | ||
diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c index 1362e8894ee1..f1fb944d714c 100644 --- a/drivers/cpufreq/sh-cpufreq.c +++ b/drivers/cpufreq/sh-cpufreq.c | |||
@@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy) | |||
87 | if (freq_table) | 87 | if (freq_table) |
88 | return cpufreq_frequency_table_verify(policy, freq_table); | 88 | return cpufreq_frequency_table_verify(policy, freq_table); |
89 | 89 | ||
90 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 90 | cpufreq_verify_within_cpu_limits(policy); |
91 | policy->cpuinfo.max_freq); | ||
92 | 91 | ||
93 | policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; | 92 | policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; |
94 | policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; | 93 | policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; |
95 | 94 | ||
96 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 95 | cpufreq_verify_within_cpu_limits(policy); |
97 | policy->cpuinfo.max_freq); | ||
98 | |||
99 | return 0; | 96 | return 0; |
100 | } | 97 | } |
101 | 98 | ||
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index b225f04d8ae5..14e6d3106355 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c | |||
@@ -29,9 +29,7 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy) | |||
29 | if (policy->cpu) | 29 | if (policy->cpu) |
30 | return -EINVAL; | 30 | return -EINVAL; |
31 | 31 | ||
32 | cpufreq_verify_within_limits(policy, | 32 | cpufreq_verify_within_cpu_limits(policy); |
33 | policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); | ||
34 | |||
35 | return 0; | 33 | return 0; |
36 | } | 34 | } |
37 | 35 | ||