[Cbe-oss-dev] [PATCH] fix cbe_thermal for legacy SLOF tree.
Jean-Christophe Dubois
jdubois at mc.com
Tue Jun 26 22:59:06 EST 2007
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 at tribudubois.net>
Index: linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_thermal.c
===================================================================
--- linux-2.6.22-rc4.orig/arch/powerpc/platforms/cell/cbe_thermal.c
+++ linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -108,6 +108,11 @@ static ssize_t spu_show_temp(struct sys_
pmd_regs = get_pmd_regs(sysdev);
+ if (!pmd_regs) {
+ WARN_ON_ONCE(!pmd_regs);
+ return 0;
+ }
+
value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1);
return sprintf(buf, "%d\n", reg_to_temp(value));
@@ -117,6 +122,11 @@ static ssize_t show_throttle(struct cbe_
{
u64 value;
+ if (!pmd_regs) {
+ WARN_ON_ONCE(!pmd_regs);
+ return 0;
+ }
+
value = in_be64(&pmd_regs->tm_tpr.val);
/* access the corresponding byte */
value >>= pos;
@@ -186,6 +196,12 @@ static ssize_t ppe_show_temp(struct sys_
u64 value;
pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
+
+ if (!pmd_regs) {
+ WARN_ON_ONCE(!pmd_regs);
+ return 0;
+ }
+
value = in_be64(&pmd_regs->ts_ctsr2);
value = (value >> pos) & 0x3f;
@@ -339,8 +355,19 @@ static void __init init_default_values(v
for_each_possible_cpu (cpu) {
pr_debug("processing cpu %d\n", cpu);
sysdev = get_cpu_sysdev(cpu);
+
+ if (!sysdev) {
+ WARN_ON_ONCE(!sysdev);
+ continue;
+ }
+
pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
+ if (!pmd_regs) {
+ WARN_ON_ONCE(!pmd_regs);
+ continue;
+ }
+
out_be64(&pmd_regs->tm_str2, str2);
out_be64(&pmd_regs->tm_str1.val, str1.val);
out_be64(&pmd_regs->tm_tpr.val, tpr.val);
More information about the cbe-oss-dev
mailing list