X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmacintosh%2Ftherm_adt746x.c;h=5ebfd1d138dafc027d3c1c0ed37f926e010f0834;hb=3995f4c5327595b51482bdac8c189736262eb6e0;hp=d09308f30960533a25dc1fe0959236f0c144078a;hpb=105adfc63f921a9976c5abc4ff079e9fec197ed7;p=linux-2.6 diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index d09308f309..5ebfd1d138 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -52,6 +52,7 @@ static char *sensor_location[3] = {NULL, NULL, NULL}; static int limit_adjust = 0; static int fan_speed = -1; +static int verbose = 0; MODULE_AUTHOR("Colin Leroy "); 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]); @@ -171,9 +176,9 @@ detach_thermostat(struct i2c_adapter *adapter) } static struct i2c_driver thermostat_driver = { - .owner = THIS_MODULE, - .name = "therm_adt746x", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "therm_adt746x", + }, .attach_adapter = attach_thermostat, .detach_adapter = detach_thermostat, }; @@ -212,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; @@ -298,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) { @@ -309,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); } } @@ -328,9 +337,7 @@ static int monitor_task(void *arg) struct thermostat* th = arg; while(!kthread_should_stop()) { - if (current->flags & PF_FREEZE) - refrigerator(PF_FREEZE); - + try_to_freeze(); msleep_interruptible(2000); #ifndef DEBUG @@ -408,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], @@ -455,21 +462,22 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, * pass around to the attribute functions, so we don't really have * choice but implement a bunch of them... * + * FIXME, it does now... */ #define BUILD_SHOW_FUNC_INT(name, data) \ -static ssize_t show_##name(struct device *dev, char *buf) \ +static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return sprintf(buf, "%d\n", data); \ } #define BUILD_SHOW_FUNC_STR(name, data) \ -static ssize_t show_##name(struct device *dev, char *buf) \ +static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return sprintf(buf, "%s\n", data); \ } #define BUILD_SHOW_FUNC_FAN(name, data) \ -static ssize_t show_##name(struct device *dev, char *buf) \ +static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ { \ return sprintf(buf, "%d (%d rpm)\n", \ thermostat->last_speed[data], \ @@ -478,7 +486,7 @@ static ssize_t show_##name(struct device *dev, char *buf) \ } #define BUILD_STORE_FUNC_DEG(name, data) \ -static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \ +static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \ { \ int val; \ int i; \ @@ -491,7 +499,7 @@ static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \ } #define BUILD_STORE_FUNC_INT(name, data) \ -static ssize_t store_##name(struct device *dev, const char *buf, size_t n) \ +static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \ { \ u32 val; \ val = simple_strtoul(buf, NULL, 10); \ @@ -600,7 +608,7 @@ thermostat_init(void) sensor_location[2] = "?"; } - of_dev = of_platform_device_create(np, "temperatures"); + of_dev = of_platform_device_create(np, "temperatures", NULL); if (of_dev == NULL) { printk(KERN_ERR "Can't register temperatures device !\n");