aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-10-03 10:58:17 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-10-15 18:50:26 -0400
commitd63bd27fe953daa402a108e141c36dcc59c6931c (patch)
tree64aefd0bf380dfca51ea3861eb111b805683edc5 /drivers
parent2633a46c581baa2a9bc33737dfbc792745e30554 (diff)
cpufreq: powernow: Use generic cpufreq routines
Most of the CPUFreq drivers do similar things in .exit() and .verify() routines and .attr. So its better if we have generic routines for them which can be used by cpufreq drivers then. This patch uses these generic routines in the powernow driver. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpufreq/powernow-k6.c22
-rw-r--r--drivers/cpufreq/powernow-k7.c14
-rw-r--r--drivers/cpufreq/powernow-k8.c20
3 files changed, 6 insertions, 50 deletions
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index ab1de0d25099..ff05d284e48e 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -105,19 +105,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
105 105
106 106
107/** 107/**
108 * powernow_k6_verify - verifies a new CPUfreq policy
109 * @policy: new policy
110 *
111 * Policy must be within lowest and highest possible CPU Frequency,
112 * and at least one possible state must be within min and max.
113 */
114static int powernow_k6_verify(struct cpufreq_policy *policy)
115{
116 return cpufreq_frequency_table_verify(policy, &clock_ratio[0]);
117}
118
119
120/**
121 * powernow_k6_setpolicy - sets a new CPUFreq policy 108 * powernow_k6_setpolicy - sets a new CPUFreq policy
122 * @policy: new policy 109 * @policy: new policy
123 * @target_freq: the target frequency 110 * @target_freq: the target frequency
@@ -188,19 +175,14 @@ static unsigned int powernow_k6_get(unsigned int cpu)
188 return ret; 175 return ret;
189} 176}
190 177
191static struct freq_attr *powernow_k6_attr[] = {
192 &cpufreq_freq_attr_scaling_available_freqs,
193 NULL,
194};
195
196static struct cpufreq_driver powernow_k6_driver = { 178static struct cpufreq_driver powernow_k6_driver = {
197 .verify = powernow_k6_verify, 179 .verify = cpufreq_generic_frequency_table_verify,
198 .target = powernow_k6_target, 180 .target = powernow_k6_target,
199 .init = powernow_k6_cpu_init, 181 .init = powernow_k6_cpu_init,
200 .exit = powernow_k6_cpu_exit, 182 .exit = powernow_k6_cpu_exit,
201 .get = powernow_k6_get, 183 .get = powernow_k6_get,
202 .name = "powernow-k6", 184 .name = "powernow-k6",
203 .attr = powernow_k6_attr, 185 .attr = cpufreq_generic_attr,
204}; 186};
205 187
206static const struct x86_cpu_id powernow_k6_ids[] = { 188static const struct x86_cpu_id powernow_k6_ids[] = {
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index c863c13dfcc8..14cd98f5a096 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -549,11 +549,6 @@ static int powernow_target(struct cpufreq_policy *policy,
549} 549}
550 550
551 551
552static int powernow_verify(struct cpufreq_policy *policy)
553{
554 return cpufreq_frequency_table_verify(policy, powernow_table);
555}
556
557/* 552/*
558 * We use the fact that the bus frequency is somehow 553 * We use the fact that the bus frequency is somehow
559 * a multiple of 100000/3 khz, then we compute sgtc according 554 * a multiple of 100000/3 khz, then we compute sgtc according
@@ -699,13 +694,8 @@ static int powernow_cpu_exit(struct cpufreq_policy *policy)
699 return 0; 694 return 0;
700} 695}
701 696
702static struct freq_attr *powernow_table_attr[] = {
703 &cpufreq_freq_attr_scaling_available_freqs,
704 NULL,
705};
706
707static struct cpufreq_driver powernow_driver = { 697static struct cpufreq_driver powernow_driver = {
708 .verify = powernow_verify, 698 .verify = cpufreq_generic_frequency_table_verify,
709 .target = powernow_target, 699 .target = powernow_target,
710 .get = powernow_get, 700 .get = powernow_get,
711#ifdef CONFIG_X86_POWERNOW_K7_ACPI 701#ifdef CONFIG_X86_POWERNOW_K7_ACPI
@@ -714,7 +704,7 @@ static struct cpufreq_driver powernow_driver = {
714 .init = powernow_cpu_init, 704 .init = powernow_cpu_init,
715 .exit = powernow_cpu_exit, 705 .exit = powernow_cpu_exit,
716 .name = "powernow-k7", 706 .name = "powernow-k7",
717 .attr = powernow_table_attr, 707 .attr = cpufreq_generic_attr,
718}; 708};
719 709
720static int __init powernow_init(void) 710static int __init powernow_init(void)
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 8d4114a043b3..1e6f68af87a4 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1053,17 +1053,6 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1053 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta); 1053 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
1054} 1054}
1055 1055
1056/* Driver entry point to verify the policy and range of frequencies */
1057static int powernowk8_verify(struct cpufreq_policy *pol)
1058{
1059 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
1060
1061 if (!data)
1062 return -EINVAL;
1063
1064 return cpufreq_frequency_table_verify(pol, data->powernow_table);
1065}
1066
1067struct init_on_cpu { 1056struct init_on_cpu {
1068 struct powernow_k8_data *data; 1057 struct powernow_k8_data *data;
1069 int rc; 1058 int rc;
@@ -1225,20 +1214,15 @@ out:
1225 return khz; 1214 return khz;
1226} 1215}
1227 1216
1228static struct freq_attr *powernow_k8_attr[] = {
1229 &cpufreq_freq_attr_scaling_available_freqs,
1230 NULL,
1231};
1232
1233static struct cpufreq_driver cpufreq_amd64_driver = { 1217static struct cpufreq_driver cpufreq_amd64_driver = {
1234 .verify = powernowk8_verify, 1218 .verify = cpufreq_generic_frequency_table_verify,
1235 .target = powernowk8_target, 1219 .target = powernowk8_target,
1236 .bios_limit = acpi_processor_get_bios_limit, 1220 .bios_limit = acpi_processor_get_bios_limit,
1237 .init = powernowk8_cpu_init, 1221 .init = powernowk8_cpu_init,
1238 .exit = powernowk8_cpu_exit, 1222 .exit = powernowk8_cpu_exit,
1239 .get = powernowk8_get, 1223 .get = powernowk8_get,
1240 .name = "powernow-k8", 1224 .name = "powernow-k8",
1241 .attr = powernow_k8_attr, 1225 .attr = cpufreq_generic_attr,
1242}; 1226};
1243 1227
1244static void __request_acpi_cpufreq(void) 1228static void __request_acpi_cpufreq(void)