diff options
author | Olof Johansson <olof@lixom.net> | 2007-04-27 22:49:03 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-04-29 21:02:05 -0400 |
commit | 4bd4aa1967628fa85a40936410acab6b8bbae6f5 (patch) | |
tree | dc87fb28576175884ba17f371685cc5cfd564d70 | |
parent | d169d140944a67edd6f88f78b65b3117059f4380 (diff) |
[POWERPC] cell: cbe_cpufreq cleanup and crash fix
cbe_cpufreq cleanups:
* comment format
* whitespace
* don't init on non-cell platforms
Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Christian Krafft <krafft@de.ibm.com>
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/platforms/cell/cbe_cpufreq.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c index 4495973bff59..f9ac3fe3be97 100644 --- a/arch/powerpc/platforms/cell/cbe_cpufreq.c +++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <asm/hw_irq.h> | 26 | #include <asm/hw_irq.h> |
27 | #include <asm/io.h> | 27 | #include <asm/io.h> |
28 | #include <asm/machdep.h> | ||
28 | #include <asm/processor.h> | 29 | #include <asm/processor.h> |
29 | #include <asm/prom.h> | 30 | #include <asm/prom.h> |
30 | #include <asm/time.h> | 31 | #include <asm/time.h> |
@@ -155,7 +156,7 @@ static int set_pmode_reg(int cpu, unsigned int pmode) | |||
155 | } | 156 | } |
156 | 157 | ||
157 | static int set_pmode(int cpu, unsigned int slow_mode) { | 158 | static int set_pmode(int cpu, unsigned int slow_mode) { |
158 | if(pmi_dev) | 159 | if (pmi_dev) |
159 | return set_pmode_pmi(cpu, slow_mode); | 160 | return set_pmode_pmi(cpu, slow_mode); |
160 | else | 161 | else |
161 | return set_pmode_reg(cpu, slow_mode); | 162 | return set_pmode_reg(cpu, slow_mode); |
@@ -167,7 +168,7 @@ static void cbe_cpufreq_handle_pmi(struct of_device *dev, pmi_message_t pmi_msg) | |||
167 | u8 cpu; | 168 | u8 cpu; |
168 | u8 cbe_pmode_new; | 169 | u8 cbe_pmode_new; |
169 | 170 | ||
170 | BUG_ON (pmi_msg.type != PMI_TYPE_FREQ_CHANGE); | 171 | BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE); |
171 | 172 | ||
172 | cpu = cbe_node_to_cpu(pmi_msg.data1); | 173 | cpu = cbe_node_to_cpu(pmi_msg.data1); |
173 | cbe_pmode_new = pmi_msg.data2; | 174 | cbe_pmode_new = pmi_msg.data2; |
@@ -191,7 +192,7 @@ static struct pmi_handler cbe_pmi_handler = { | |||
191 | * cpufreq functions | 192 | * cpufreq functions |
192 | */ | 193 | */ |
193 | 194 | ||
194 | static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy) | 195 | static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) |
195 | { | 196 | { |
196 | const u32 *max_freqp; | 197 | const u32 *max_freqp; |
197 | u32 max_freq; | 198 | u32 max_freq; |
@@ -200,7 +201,7 @@ static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy) | |||
200 | 201 | ||
201 | cpu = of_get_cpu_node(policy->cpu, NULL); | 202 | cpu = of_get_cpu_node(policy->cpu, NULL); |
202 | 203 | ||
203 | if(!cpu) | 204 | if (!cpu) |
204 | return -ENODEV; | 205 | return -ENODEV; |
205 | 206 | ||
206 | pr_debug("init cpufreq on CPU %d\n", policy->cpu); | 207 | pr_debug("init cpufreq on CPU %d\n", policy->cpu); |
@@ -210,13 +211,13 @@ static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy) | |||
210 | if (!max_freqp) | 211 | if (!max_freqp) |
211 | return -EINVAL; | 212 | return -EINVAL; |
212 | 213 | ||
213 | // we need the freq in kHz | 214 | /* we need the freq in kHz */ |
214 | max_freq = *max_freqp / 1000; | 215 | max_freq = *max_freqp / 1000; |
215 | 216 | ||
216 | pr_debug("max clock-frequency is at %u kHz\n", max_freq); | 217 | pr_debug("max clock-frequency is at %u kHz\n", max_freq); |
217 | pr_debug("initializing frequency table\n"); | 218 | pr_debug("initializing frequency table\n"); |
218 | 219 | ||
219 | // initialize frequency table | 220 | /* initialize frequency table */ |
220 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 221 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { |
221 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; | 222 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; |
222 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); | 223 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); |
@@ -235,10 +236,10 @@ static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy) | |||
235 | policy->cpus = cpu_sibling_map[policy->cpu]; | 236 | policy->cpus = cpu_sibling_map[policy->cpu]; |
236 | #endif | 237 | #endif |
237 | 238 | ||
238 | cpufreq_frequency_table_get_attr (cbe_freqs, policy->cpu); | 239 | cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu); |
239 | 240 | ||
240 | /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */ | 241 | /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */ |
241 | return cpufreq_frequency_table_cpuinfo (policy, cbe_freqs); | 242 | return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs); |
242 | } | 243 | } |
243 | 244 | ||
244 | static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) | 245 | static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) |
@@ -270,7 +271,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target | |||
270 | freqs.new = cbe_freqs[cbe_pmode_new].frequency; | 271 | freqs.new = cbe_freqs[cbe_pmode_new].frequency; |
271 | freqs.cpu = policy->cpu; | 272 | freqs.cpu = policy->cpu; |
272 | 273 | ||
273 | mutex_lock (&cbe_switch_mutex); | 274 | mutex_lock(&cbe_switch_mutex); |
274 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 275 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
275 | 276 | ||
276 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", | 277 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", |
@@ -303,6 +304,9 @@ static int __init cbe_cpufreq_init(void) | |||
303 | { | 304 | { |
304 | struct device_node *np; | 305 | struct device_node *np; |
305 | 306 | ||
307 | if (!machine_is(cell)) | ||
308 | return -ENODEV; | ||
309 | |||
306 | np = of_find_node_by_type(NULL, "ibm,pmi"); | 310 | np = of_find_node_by_type(NULL, "ibm,pmi"); |
307 | 311 | ||
308 | pmi_dev = of_find_device_by_node(np); | 312 | pmi_dev = of_find_device_by_node(np); |
@@ -315,7 +319,7 @@ static int __init cbe_cpufreq_init(void) | |||
315 | 319 | ||
316 | static void __exit cbe_cpufreq_exit(void) | 320 | static void __exit cbe_cpufreq_exit(void) |
317 | { | 321 | { |
318 | if(pmi_dev) | 322 | if (pmi_dev) |
319 | pmi_unregister_handler(pmi_dev, &cbe_pmi_handler); | 323 | pmi_unregister_handler(pmi_dev, &cbe_pmi_handler); |
320 | 324 | ||
321 | cpufreq_unregister_driver(&cbe_cpufreq_driver); | 325 | cpufreq_unregister_driver(&cbe_cpufreq_driver); |