aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/sparc-us2e-cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-10-25 10:15:48 -0400
committerRafael J. Wysocki <rjw@rjwysocki.net>2013-10-25 16:42:24 -0400
commit9c0ebcf78fde0ffa348a95a544c6d3f2dac5af65 (patch)
tree0aa1814b3cdbd6900a6494d8f0c56551d90cf693 /drivers/cpufreq/sparc-us2e-cpufreq.c
parent6ddee424fea2d269c2f402278d93165c7b92dc58 (diff)
cpufreq: Implement light weight ->target_index() routine
Currently, the prototype of cpufreq_drivers target routines is: int target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation); And most of the drivers call cpufreq_frequency_table_target() to get a valid index of their frequency table which is closest to the target_freq. And they don't use target_freq and relation after that. So, it makes sense to just do this work in cpufreq core before calling cpufreq_frequency_table_target() and simply pass index instead. But this can be done only with drivers which expose their frequency table with cpufreq core. For others we need to stick with the old prototype of target() until those drivers are converted to expose frequency tables. This patch implements the new light weight prototype for target_index() routine. It looks like this: int target_index(struct cpufreq_policy *policy, unsigned int index); CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and pass index to it. Because CPUFreq core now requires to call routines present in freq_table.c CONFIG_CPU_FREQ_TABLE must be enabled all the time. This also marks target() interface as deprecated. So, that new drivers avoid using it. And Documentation is updated accordingly. It also converts existing .target() to newly defined light weight .target_index() routine for many driver. Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Russell King <linux@arm.linux.org.uk> Acked-by: David S. Miller <davem@davemloft.net> Tested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rjw@rjwysocki.net>
Diffstat (limited to 'drivers/cpufreq/sparc-us2e-cpufreq.c')
-rw-r--r--drivers/cpufreq/sparc-us2e-cpufreq.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index 291688c1da9a..3bf5b8f03661 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -245,8 +245,7 @@ static unsigned int us2e_freq_get(unsigned int cpu)
245 return clock_tick / estar_to_divisor(estar); 245 return clock_tick / estar_to_divisor(estar);
246} 246}
247 247
248static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy, 248static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)
249 unsigned int index)
250{ 249{
251 unsigned int cpu = policy->cpu; 250 unsigned int cpu = policy->cpu;
252 unsigned long new_bits, new_freq; 251 unsigned long new_bits, new_freq;
@@ -277,20 +276,6 @@ static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,
277 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); 276 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
278 277
279 set_cpus_allowed_ptr(current, &cpus_allowed); 278 set_cpus_allowed_ptr(current, &cpus_allowed);
280}
281
282static int us2e_freq_target(struct cpufreq_policy *policy,
283 unsigned int target_freq,
284 unsigned int relation)
285{
286 unsigned int new_index = 0;
287
288 if (cpufreq_frequency_table_target(policy,
289 &us2e_freq_table[policy->cpu].table[0],
290 target_freq, relation, &new_index))
291 return -EINVAL;
292
293 us2e_set_cpu_divider_index(policy, new_index);
294 279
295 return 0; 280 return 0;
296} 281}
@@ -325,7 +310,7 @@ static int us2e_freq_cpu_exit(struct cpufreq_policy *policy)
325{ 310{
326 if (cpufreq_us2e_driver) { 311 if (cpufreq_us2e_driver) {
327 cpufreq_frequency_table_put_attr(policy->cpu); 312 cpufreq_frequency_table_put_attr(policy->cpu);
328 us2e_set_cpu_divider_index(policy, 0); 313 us2e_freq_target(policy, 0);
329 } 314 }
330 315
331 return 0; 316 return 0;
@@ -358,7 +343,7 @@ static int __init us2e_freq_init(void)
358 343
359 driver->init = us2e_freq_cpu_init; 344 driver->init = us2e_freq_cpu_init;
360 driver->verify = cpufreq_generic_frequency_table_verify; 345 driver->verify = cpufreq_generic_frequency_table_verify;
361 driver->target = us2e_freq_target; 346 driver->target_index = us2e_freq_target;
362 driver->get = us2e_freq_get; 347 driver->get = us2e_freq_get;
363 driver->exit = us2e_freq_cpu_exit; 348 driver->exit = us2e_freq_cpu_exit;
364 strcpy(driver->name, "UltraSPARC-IIe"); 349 strcpy(driver->name, "UltraSPARC-IIe");