Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.git] / drivers / macintosh / therm_adt746x.c
index 276945d..5366dc9 100644 (file)
@@ -553,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)
@@ -561,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) {
@@ -609,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");