aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christophe DUBOIS <jcd@tribudubois.net>2007-07-20 15:39:24 -0400
committerArnd Bergmann <arnd@klappe.arndb.de>2007-07-20 15:41:40 -0400
commit827e3648dc2c31e01db7cd2e4498061cf78a97a9 (patch)
treef34d99cd990b417b34754024ab28a4eba0abd3a5
parent64bafa9db7e92d5a46402613188b71800924ca1f (diff)
[CELL] fix cbe_thermal for legacy SLOF tree.
Previous patch changed based on Christian Krafft's comment. On some legacy SLOF tree the generic code is unable to ioremap some Cell BE registers. Therefore the "generic" functions are returning a NULL pointer, triggering a crash on such platforms. Let's handle this more gracefully. Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net> Acked-by: Christian Kraff <krafft@de.ibm.com> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
-rw-r--r--arch/powerpc/platforms/cell/cbe_thermal.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
index f370f0fa6f4c..e4132f8f51b3 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -292,7 +292,7 @@ static struct attribute_group ppe_attribute_group = {
292/* 292/*
293 * initialize throttling with default values 293 * initialize throttling with default values
294 */ 294 */
295static void __init init_default_values(void) 295static int __init init_default_values(void)
296{ 296{
297 int cpu; 297 int cpu;
298 struct cbe_pmd_regs __iomem *pmd_regs; 298 struct cbe_pmd_regs __iomem *pmd_regs;
@@ -339,25 +339,40 @@ static void __init init_default_values(void)
339 for_each_possible_cpu (cpu) { 339 for_each_possible_cpu (cpu) {
340 pr_debug("processing cpu %d\n", cpu); 340 pr_debug("processing cpu %d\n", cpu);
341 sysdev = get_cpu_sysdev(cpu); 341 sysdev = get_cpu_sysdev(cpu);
342
343 if (!sysdev) {
344 pr_info("invalid sysdev pointer for cbe_thermal\n");
345 return -EINVAL;
346 }
347
342 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); 348 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
343 349
350 if (!pmd_regs) {
351 pr_info("invalid CBE regs pointer for cbe_thermal\n");
352 return -EINVAL;
353 }
354
344 out_be64(&pmd_regs->tm_str2, str2); 355 out_be64(&pmd_regs->tm_str2, str2);
345 out_be64(&pmd_regs->tm_str1.val, str1.val); 356 out_be64(&pmd_regs->tm_str1.val, str1.val);
346 out_be64(&pmd_regs->tm_tpr.val, tpr.val); 357 out_be64(&pmd_regs->tm_tpr.val, tpr.val);
347 out_be64(&pmd_regs->tm_cr1.val, cr1.val); 358 out_be64(&pmd_regs->tm_cr1.val, cr1.val);
348 out_be64(&pmd_regs->tm_cr2, cr2); 359 out_be64(&pmd_regs->tm_cr2, cr2);
349 } 360 }
361
362 return 0;
350} 363}
351 364
352 365
353static int __init thermal_init(void) 366static int __init thermal_init(void)
354{ 367{
355 init_default_values(); 368 int rc = init_default_values();
356 369
357 spu_add_sysdev_attr_group(&spu_attribute_group); 370 if (rc == 0) {
358 cpu_add_sysdev_attr_group(&ppe_attribute_group); 371 spu_add_sysdev_attr_group(&spu_attribute_group);
372 cpu_add_sysdev_attr_group(&ppe_attribute_group);
373 }
359 374
360 return 0; 375 return rc;
361} 376}
362module_init(thermal_init); 377module_init(thermal_init);
363 378