]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/macintosh/therm_adt746x.c
macintosh: Use linux/of_{device,platform}.h instead of asm
[linux-2.6-omap-h63xx.git] / drivers / macintosh / therm_adt746x.c
index f25685b9b7cf51a782c24faaa86bf9b896e4acca..22bf981d393b4e9ec9a0ff7253e4640e4db8bd9a 100644 (file)
 #include <linux/kthread.h>
 #include <linux/moduleparam.h>
 #include <linux/freezer.h>
+#include <linux/of_platform.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/sections.h>
-#include <asm/of_platform.h>
 
 #undef DEBUG
 
@@ -379,13 +379,10 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
        if (thermostat)
                return 0;
 
-       th = (struct thermostat *)
-               kmalloc(sizeof(struct thermostat), GFP_KERNEL);
-
+       th = kzalloc(sizeof(struct thermostat), GFP_KERNEL);
        if (!th)
                return -ENOMEM;
 
-       memset(th, 0, sizeof(*th));
        th->clt.addr = addr;
        th->clt.adapter = adapter;
        th->clt.driver = &thermostat_driver;
@@ -556,6 +553,7 @@ thermostat_init(void)
        struct device_node* np;
        const u32 *prop;
        int i = 0, offset = 0;
+       int err;
        
        np = of_find_node_by_name(NULL, "fan");
        if (!np)
@@ -564,18 +562,24 @@ thermostat_init(void)
                therm_type = ADT7460;
        else if (of_device_is_compatible(np, "adt7467"))
                therm_type = ADT7467;
-       else
+       else {
+               of_node_put(np);
                return -ENODEV;
+       }
 
        prop = of_get_property(np, "hwsensor-params-version", NULL);
        printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
                         (*prop == 1)?"":"un");
-       if (*prop != 1)
+       if (*prop != 1) {
+               of_node_put(np);
                return -ENODEV;
+       }
 
        prop = of_get_property(np, "reg", NULL);
-       if (!prop)
+       if (!prop) {
+               of_node_put(np);
                return -ENODEV;
+       }
 
        /* look for bus either by path or using "reg" */
        if (strstr(np->full_name, "/i2c-bus@") != NULL) {
@@ -612,20 +616,24 @@ thermostat_init(void)
        
        if (of_dev == NULL) {
                printk(KERN_ERR "Can't register temperatures device !\n");
+               of_node_put(np);
                return -ENODEV;
        }
        
-       device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
-       device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
-       device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
-       device_create_file(&of_dev->dev, &dev_attr_sensor2_limit);
-       device_create_file(&of_dev->dev, &dev_attr_sensor1_location);
-       device_create_file(&of_dev->dev, &dev_attr_sensor2_location);
-       device_create_file(&of_dev->dev, &dev_attr_limit_adjust);
-       device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed);
-       device_create_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
+       err = device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_limit);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_limit);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_location);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_location);
+       err |= device_create_file(&of_dev->dev, &dev_attr_limit_adjust);
+       err |= device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed);
+       err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_fan_speed);
        if(therm_type == ADT7460)
-               device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed);
+               err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed);
+       if (err)
+               printk(KERN_WARNING
+                       "Failed to create tempertaure attribute file(s).\n");
 
 #ifndef CONFIG_I2C_POWERMAC
        request_module("i2c-powermac");