Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
be49e346 0b981e70

+19 -33
+1 -3
drivers/cpufreq/cpufreq-nforce2.c
··· 303 303 if (policy->min < (fsb_pol_max * fid * 100)) 304 304 policy->max = (fsb_pol_max + 1) * fid * 100; 305 305 306 - cpufreq_verify_within_limits(policy, 307 - policy->cpuinfo.min_freq, 308 - policy->cpuinfo.max_freq); 306 + cpufreq_verify_within_cpu_limits(policy); 309 307 return 0; 310 308 } 311 309
+1 -3
drivers/cpufreq/davinci-cpufreq.c
··· 50 50 if (policy->cpu) 51 51 return -EINVAL; 52 52 53 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 54 - policy->cpuinfo.max_freq); 55 - 53 + cpufreq_verify_within_cpu_limits(policy); 56 54 policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; 57 55 policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; 58 56 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
+2 -4
drivers/cpufreq/freq_table.c
··· 60 60 pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", 61 61 policy->min, policy->max, policy->cpu); 62 62 63 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 64 - policy->cpuinfo.max_freq); 63 + cpufreq_verify_within_cpu_limits(policy); 65 64 66 65 for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { 67 66 if (freq == CPUFREQ_ENTRY_INVALID) ··· 76 77 77 78 if (!found) { 78 79 policy->max = next_larger; 79 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 80 - policy->cpuinfo.max_freq); 80 + cpufreq_verify_within_cpu_limits(policy); 81 81 } 82 82 83 83 pr_debug("verification lead to (%u - %u kHz) for cpu %u\n",
+2 -7
drivers/cpufreq/integrator-cpufreq.c
··· 59 59 { 60 60 struct icst_vco vco; 61 61 62 - cpufreq_verify_within_limits(policy, 63 - policy->cpuinfo.min_freq, 64 - policy->cpuinfo.max_freq); 62 + cpufreq_verify_within_cpu_limits(policy); 65 63 66 64 vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); 67 65 policy->max = icst_hz(&cclk_params, vco) / 1000; ··· 67 69 vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); 68 70 policy->min = icst_hz(&cclk_params, vco) / 1000; 69 71 70 - cpufreq_verify_within_limits(policy, 71 - policy->cpuinfo.min_freq, 72 - policy->cpuinfo.max_freq); 73 - 72 + cpufreq_verify_within_cpu_limits(policy); 74 73 return 0; 75 74 } 76 75
+1 -3
drivers/cpufreq/intel_pstate.c
··· 611 611 612 612 static int intel_pstate_verify_policy(struct cpufreq_policy *policy) 613 613 { 614 - cpufreq_verify_within_limits(policy, 615 - policy->cpuinfo.min_freq, 616 - policy->cpuinfo.max_freq); 614 + cpufreq_verify_within_cpu_limits(policy); 617 615 618 616 if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && 619 617 (policy->policy != CPUFREQ_POLICY_PERFORMANCE))
+1 -3
drivers/cpufreq/longrun.c
··· 129 129 return -EINVAL; 130 130 131 131 policy->cpu = 0; 132 - cpufreq_verify_within_limits(policy, 133 - policy->cpuinfo.min_freq, 134 - policy->cpuinfo.max_freq); 132 + cpufreq_verify_within_cpu_limits(policy); 135 133 136 134 if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && 137 135 (policy->policy != CPUFREQ_POLICY_PERFORMANCE))
+1 -2
drivers/cpufreq/pcc-cpufreq.c
··· 111 111 112 112 static int pcc_cpufreq_verify(struct cpufreq_policy *policy) 113 113 { 114 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 115 - policy->cpuinfo.max_freq); 114 + cpufreq_verify_within_cpu_limits(policy); 116 115 return 0; 117 116 } 118 117
+2 -5
drivers/cpufreq/sh-cpufreq.c
··· 87 87 if (freq_table) 88 88 return cpufreq_frequency_table_verify(policy, freq_table); 89 89 90 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 91 - policy->cpuinfo.max_freq); 90 + cpufreq_verify_within_cpu_limits(policy); 92 91 93 92 policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; 94 93 policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; 95 94 96 - cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 97 - policy->cpuinfo.max_freq); 98 - 95 + cpufreq_verify_within_cpu_limits(policy); 99 96 return 0; 100 97 } 101 98
+1 -3
drivers/cpufreq/unicore2-cpufreq.c
··· 29 29 if (policy->cpu) 30 30 return -EINVAL; 31 31 32 - cpufreq_verify_within_limits(policy, 33 - policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); 34 - 32 + cpufreq_verify_within_cpu_limits(policy); 35 33 return 0; 36 34 } 37 35
+7
include/linux/cpufreq.h
··· 242 242 return; 243 243 } 244 244 245 + static inline void 246 + cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) 247 + { 248 + cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, 249 + policy->cpuinfo.max_freq); 250 + } 251 + 245 252 /********************************************************************* 246 253 * CPUFREQ NOTIFIER INTERFACE * 247 254 *********************************************************************/