]> err.no Git - linux-2.6/blobdiff - drivers/macintosh/therm_adt746x.c
Pull sony into release branch
[linux-2.6] / drivers / macintosh / therm_adt746x.c
index 8bb1d857e14d628bb1bfd0c5dd02633a0d5894c7..a7ce559266380596a045657ed14ae12efd4f5bb6 100644 (file)
@@ -9,7 +9,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/suspend.h>
 #include <linux/kthread.h>
 #include <linux/moduleparam.h>
+#include <linux/freezer.h>
 
 #include <asm/prom.h>
 #include <asm/machdep.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/sections.h>
-#include <asm/of_device.h>
+#include <asm/of_platform.h>
 
 #undef DEBUG
 
@@ -48,10 +48,11 @@ static u8 FAN_SPD_SET[2] = {0x30, 0x31};
 
 static u8 default_limits_local[3] = {70, 50, 70};    /* local, sensor1, sensor2 */
 static u8 default_limits_chip[3] = {80, 65, 80};    /* local, sensor1, sensor2 */
-static char *sensor_location[3] = {NULL, NULL, NULL};
+static const char *sensor_location[3];
 
-static int limit_adjust = 0;
+static int limit_adjust;
 static int fan_speed = -1;
+static int verbose;
 
 MODULE_AUTHOR("Colin Leroy <colin@colino.net>");
 MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
@@ -66,6 +67,10 @@ module_param(fan_speed, int, 0644);
 MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) "
                 "(default 64)");
 
+module_param(verbose, bool, 0);
+MODULE_PARM_DESC(verbose,"Verbose log operations "
+                "(default 0)");
+
 struct thermostat {
        struct i2c_client       clt;
        u8                      temps[3];
@@ -149,13 +154,13 @@ detach_thermostat(struct i2c_adapter *adapter)
        if (thread_therm != NULL) {
                kthread_stop(thread_therm);
        }
-               
+
        printk(KERN_INFO "adt746x: Putting max temperatures back from "
                         "%d, %d, %d to %d, %d, %d\n",
                th->limits[0], th->limits[1], th->limits[2],
                th->initial_limits[0], th->initial_limits[1],
                th->initial_limits[2]);
-       
+
        for (i = 0; i < 3; i++)
                write_reg(th, LIMIT_REG[i], th->initial_limits[i]);
 
@@ -172,7 +177,6 @@ detach_thermostat(struct i2c_adapter *adapter)
 
 static struct i2c_driver thermostat_driver = {  
        .driver = {
-               .owner  = THIS_MODULE,
                .name   = "therm_adt746x",
        },
        .attach_adapter = attach_thermostat,
@@ -213,12 +217,14 @@ static void write_fan_speed(struct thermostat *th, int speed, int fan)
                return;
        
        if (th->last_speed[fan] != speed) {
-               if (speed == -1)
-                       printk(KERN_DEBUG "adt746x: Setting speed to automatic "
-                               "for %s fan.\n", sensor_location[fan+1]);
-               else
-                       printk(KERN_DEBUG "adt746x: Setting speed to %d "
-                               "for %s fan.\n", speed, sensor_location[fan+1]);
+               if (verbose) {
+                       if (speed == -1)
+                               printk(KERN_DEBUG "adt746x: Setting speed to automatic "
+                                       "for %s fan.\n", sensor_location[fan+1]);
+                       else
+                               printk(KERN_DEBUG "adt746x: Setting speed to %d "
+                                       "for %s fan.\n", speed, sensor_location[fan+1]);
+               }
        } else
                return;
        
@@ -299,10 +305,11 @@ static void update_fans_speed (struct thermostat *th)
                        if (new_speed > 255)
                                new_speed = 255;
 
-                       printk(KERN_DEBUG "adt746x: setting fans speed to %d "
-                                        "(limit exceeded by %d on %s) \n",
-                                       new_speed, var,
-                                       sensor_location[fan_number+1]);
+                       if (verbose)
+                               printk(KERN_DEBUG "adt746x: Setting fans speed to %d "
+                                                "(limit exceeded by %d on %s) \n",
+                                               new_speed, var,
+                                               sensor_location[fan_number+1]);
                        write_both_fan_speed(th, new_speed);
                        th->last_var[fan_number] = var;
                } else if (var < -2) {
@@ -310,8 +317,9 @@ static void update_fans_speed (struct thermostat *th)
                         * so cold (lastvar >= -1) */
                        if (i == 2 && lastvar < -1) {
                                if (th->last_speed[fan_number] != 0)
-                                       printk(KERN_DEBUG "adt746x: Stopping "
-                                               "fans.\n");
+                                       if (verbose)
+                                               printk(KERN_DEBUG "adt746x: Stopping "
+                                                       "fans.\n");
                                write_both_fan_speed(th, 0);
                        }
                }
@@ -407,7 +415,7 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
                th->initial_limits[i] = read_reg(th, LIMIT_REG[i]);
                set_limit(th, i);
        }
-       
+
        printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
                         " to %d, %d, %d\n",
                         th->initial_limits[0], th->initial_limits[1],
@@ -546,7 +554,7 @@ static int __init
 thermostat_init(void)
 {
        struct device_node* np;
-       u32 *prop;
+       const u32 *prop;
        int i = 0, offset = 0;
        
        np = of_find_node_by_name(NULL, "fan");
@@ -559,13 +567,13 @@ thermostat_init(void)
        else
                return -ENODEV;
 
-       prop = (u32 *)get_property(np, "hwsensor-params-version", NULL);
+       prop = get_property(np, "hwsensor-params-version", NULL);
        printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
                         (*prop == 1)?"":"un");
        if (*prop != 1)
                return -ENODEV;
 
-       prop = (u32 *)get_property(np, "reg", NULL);
+       prop = get_property(np, "reg", NULL);
        if (!prop)
                return -ENODEV;
 
@@ -619,8 +627,8 @@ thermostat_init(void)
        if(therm_type == ADT7460)
                device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed);
 
-#ifndef CONFIG_I2C_KEYWEST
-       request_module("i2c-keywest");
+#ifndef CONFIG_I2C_POWERMAC
+       request_module("i2c-powermac");
 #endif
 
        return i2c_add_driver(&thermostat_driver);