aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/powernow-k6.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/powernow-k6.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/powernow-k6.c')
-rw-r--r--drivers/cpufreq/powernow-k6.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index eda17024a34a..643e7952cad3 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -63,12 +63,12 @@ static int powernow_k6_get_cpu_multiplier(void)
63 63
64 64
65/** 65/**
66 * powernow_k6_set_state - set the PowerNow! multiplier 66 * powernow_k6_target - set the PowerNow! multiplier
67 * @best_i: clock_ratio[best_i] is the target multiplier 67 * @best_i: clock_ratio[best_i] is the target multiplier
68 * 68 *
69 * Tries to change the PowerNow! multiplier 69 * Tries to change the PowerNow! multiplier
70 */ 70 */
71static void powernow_k6_set_state(struct cpufreq_policy *policy, 71static int powernow_k6_target(struct cpufreq_policy *policy,
72 unsigned int best_i) 72 unsigned int best_i)
73{ 73{
74 unsigned long outvalue = 0, invalue = 0; 74 unsigned long outvalue = 0, invalue = 0;
@@ -77,7 +77,7 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
77 77
78 if (clock_ratio[best_i].driver_data > max_multiplier) { 78 if (clock_ratio[best_i].driver_data > max_multiplier) {
79 printk(KERN_ERR PFX "invalid target frequency\n"); 79 printk(KERN_ERR PFX "invalid target frequency\n");
80 return; 80 return -EINVAL;
81 } 81 }
82 82
83 freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); 83 freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
@@ -100,31 +100,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
100 100
101 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); 101 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
102 102
103 return;
104}
105
106
107/**
108 * powernow_k6_setpolicy - sets a new CPUFreq policy
109 * @policy: new policy
110 * @target_freq: the target frequency
111 * @relation: how that frequency relates to achieved frequency
112 * (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H)
113 *
114 * sets a new CPUFreq policy
115 */
116static int powernow_k6_target(struct cpufreq_policy *policy,
117 unsigned int target_freq,
118 unsigned int relation)
119{
120 unsigned int newstate = 0;
121
122 if (cpufreq_frequency_table_target(policy, &clock_ratio[0],
123 target_freq, relation, &newstate))
124 return -EINVAL;
125
126 powernow_k6_set_state(policy, newstate);
127
128 return 0; 103 return 0;
129} 104}
130 105
@@ -161,7 +136,7 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
161 unsigned int i; 136 unsigned int i;
162 for (i = 0; i < 8; i++) { 137 for (i = 0; i < 8; i++) {
163 if (i == max_multiplier) 138 if (i == max_multiplier)
164 powernow_k6_set_state(policy, i); 139 powernow_k6_target(policy, i);
165 } 140 }
166 cpufreq_frequency_table_put_attr(policy->cpu); 141 cpufreq_frequency_table_put_attr(policy->cpu);
167 return 0; 142 return 0;
@@ -176,7 +151,7 @@ static unsigned int powernow_k6_get(unsigned int cpu)
176 151
177static struct cpufreq_driver powernow_k6_driver = { 152static struct cpufreq_driver powernow_k6_driver = {
178 .verify = cpufreq_generic_frequency_table_verify, 153 .verify = cpufreq_generic_frequency_table_verify,
179 .target = powernow_k6_target, 154 .target_index = powernow_k6_target,
180 .init = powernow_k6_cpu_init, 155 .init = powernow_k6_cpu_init,
181 .exit = powernow_k6_cpu_exit, 156 .exit = powernow_k6_cpu_exit,
182 .get = powernow_k6_get, 157 .get = powernow_k6_get,