aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/acpi-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/acpi-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/acpi-cpufreq.c')
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index a1717d7367c1..889cec0a9022 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -424,17 +424,17 @@ static unsigned int check_freqs(const struct cpumask *mask, unsigned int freq,
424} 424}
425 425
426static int acpi_cpufreq_target(struct cpufreq_policy *policy, 426static int acpi_cpufreq_target(struct cpufreq_policy *policy,
427 unsigned int target_freq, unsigned int relation) 427 unsigned int index)
428{ 428{
429 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu); 429 struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);
430 struct acpi_processor_performance *perf; 430 struct acpi_processor_performance *perf;
431 struct cpufreq_freqs freqs; 431 struct cpufreq_freqs freqs;
432 struct drv_cmd cmd; 432 struct drv_cmd cmd;
433 unsigned int next_state = 0; /* Index into freq_table */
434 unsigned int next_perf_state = 0; /* Index into perf table */ 433 unsigned int next_perf_state = 0; /* Index into perf table */
435 int result = 0; 434 int result = 0;
436 435
437 pr_debug("acpi_cpufreq_target %d (%d)\n", target_freq, policy->cpu); 436 pr_debug("acpi_cpufreq_target %d (%d)\n",
437 data->freq_table[index].frequency, policy->cpu);
438 438
439 if (unlikely(data == NULL || 439 if (unlikely(data == NULL ||
440 data->acpi_data == NULL || data->freq_table == NULL)) { 440 data->acpi_data == NULL || data->freq_table == NULL)) {
@@ -442,16 +442,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
442 } 442 }
443 443
444 perf = data->acpi_data; 444 perf = data->acpi_data;
445 result = cpufreq_frequency_table_target(policy, 445 next_perf_state = data->freq_table[index].driver_data;
446 data->freq_table,
447 target_freq,
448 relation, &next_state);
449 if (unlikely(result)) {
450 result = -ENODEV;
451 goto out;
452 }
453
454 next_perf_state = data->freq_table[next_state].driver_data;
455 if (perf->state == next_perf_state) { 446 if (perf->state == next_perf_state) {
456 if (unlikely(data->resume)) { 447 if (unlikely(data->resume)) {
457 pr_debug("Called after resume, resetting to P%d\n", 448 pr_debug("Called after resume, resetting to P%d\n",
@@ -493,7 +484,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
493 cmd.mask = cpumask_of(policy->cpu); 484 cmd.mask = cpumask_of(policy->cpu);
494 485
495 freqs.old = perf->states[perf->state].core_frequency * 1000; 486 freqs.old = perf->states[perf->state].core_frequency * 1000;
496 freqs.new = data->freq_table[next_state].frequency; 487 freqs.new = data->freq_table[index].frequency;
497 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); 488 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
498 489
499 drv_write(&cmd); 490 drv_write(&cmd);
@@ -923,7 +914,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = {
923 914
924static struct cpufreq_driver acpi_cpufreq_driver = { 915static struct cpufreq_driver acpi_cpufreq_driver = {
925 .verify = cpufreq_generic_frequency_table_verify, 916 .verify = cpufreq_generic_frequency_table_verify,
926 .target = acpi_cpufreq_target, 917 .target_index = acpi_cpufreq_target,
927 .bios_limit = acpi_processor_get_bios_limit, 918 .bios_limit = acpi_processor_get_bios_limit,
928 .init = acpi_cpufreq_cpu_init, 919 .init = acpi_cpufreq_cpu_init,
929 .exit = acpi_cpufreq_cpu_exit, 920 .exit = acpi_cpufreq_cpu_exit,