]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/cell/cbe_thermal.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / cell / cbe_thermal.c
index f370f0fa6f4c87222cd7f679af15b3fc7f00073e..4852bf312d83c0d60a224eb9ab292dd832c96a64 100644 (file)
@@ -52,8 +52,8 @@
 #include <asm/spu.h>
 #include <asm/io.h>
 #include <asm/prom.h>
+#include <asm/cell-regs.h>
 
-#include "cbe_regs.h"
 #include "spu_priv1_mmio.h"
 
 #define TEMP_MIN 65
@@ -88,17 +88,13 @@ static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev)
 /* returns the value for a given spu in a given register */
 static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iomem *reg)
 {
-       const unsigned int *id;
        union spe_reg value;
        struct spu *spu;
 
-       /* getting the id from the reg attribute will not work on future device-tree layouts
-        * in future we should store the id to the spu struct and use it here */
        spu = container_of(sysdev, struct spu, sysdev);
-       id = of_get_property(spu_devnode(spu), "reg", NULL);
        value.val = in_be64(&reg->val);
 
-       return value.spe[*id];
+       return value.spe[spu->spe_id];
 }
 
 static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
@@ -292,7 +288,7 @@ static struct attribute_group ppe_attribute_group = {
 /*
  * initialize throttling with default values
  */
-static void __init init_default_values(void)
+static int __init init_default_values(void)
 {
        int cpu;
        struct cbe_pmd_regs __iomem *pmd_regs;
@@ -339,25 +335,40 @@ static void __init init_default_values(void)
        for_each_possible_cpu (cpu) {
                pr_debug("processing cpu %d\n", cpu);
                sysdev = get_cpu_sysdev(cpu);
+
+               if (!sysdev) {
+                       pr_info("invalid sysdev pointer for cbe_thermal\n");
+                       return -EINVAL;
+               }
+
                pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
 
+               if (!pmd_regs) {
+                       pr_info("invalid CBE regs pointer for cbe_thermal\n");
+                       return -EINVAL;
+               }
+
                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);
                out_be64(&pmd_regs->tm_cr1.val, cr1.val);
                out_be64(&pmd_regs->tm_cr2, cr2);
        }
+
+       return 0;
 }
 
 
 static int __init thermal_init(void)
 {
-       init_default_values();
+       int rc = init_default_values();
 
-       spu_add_sysdev_attr_group(&spu_attribute_group);
-       cpu_add_sysdev_attr_group(&ppe_attribute_group);
+       if (rc == 0) {
+               spu_add_sysdev_attr_group(&spu_attribute_group);
+               cpu_add_sysdev_attr_group(&ppe_attribute_group);
+       }
 
-       return 0;
+       return rc;
 }
 module_init(thermal_init);