aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-10-03 10:59:07 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-15 18:50:33 -0400
commit70e9e778337973d5bf57004092b360bd3f3c412f (patch)
tree8c8f19f60b723421764caee1926f15db36bdb35b /drivers/cpufreq/cpufreq.c
parent9909aa1e3b69eb05201bdbd2b9bde00c50c1723a (diff)
cpufreq: create cpufreq_generic_init() routine
Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part. This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f033adf06eaf..985f325adc4f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -181,6 +181,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)
181} 181}
182EXPORT_SYMBOL_GPL(get_cpu_idle_time); 182EXPORT_SYMBOL_GPL(get_cpu_idle_time);
183 183
184/*
185 * This is a generic cpufreq init() routine which can be used by cpufreq
186 * drivers of SMP systems. It will do following:
187 * - validate & show freq table passed
188 * - set policies transition latency
189 * - policy->cpus with all possible CPUs
190 */
191int cpufreq_generic_init(struct cpufreq_policy *policy,
192 struct cpufreq_frequency_table *table,
193 unsigned int transition_latency)
194{
195 int ret;
196
197 ret = cpufreq_table_validate_and_show(policy, table);
198 if (ret) {
199 pr_err("%s: invalid frequency table: %d\n", __func__, ret);
200 return ret;
201 }
202
203 policy->cpuinfo.transition_latency = transition_latency;
204
205 /*
206 * The driver only supports the SMP configuartion where all processors
207 * share the clock and voltage and clock.
208 */
209 cpumask_setall(policy->cpus);
210
211 return 0;
212}
213EXPORT_SYMBOL_GPL(cpufreq_generic_init);
214
184struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) 215struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
185{ 216{
186 struct cpufreq_policy *policy = NULL; 217 struct cpufreq_policy *policy = NULL;