aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm85.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-07-05 14:39:40 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-10-09 22:56:30 -0400
commit63f281a6e32ebc93c62dac0d399d8e054eb7b2ec (patch)
treed60cf42951a3d274f263788f6f54c06695b2e41f /drivers/hwmon/lm85.c
parent5a4d3ef317c845893fe3f9d3517cb0a99375da53 (diff)
hwmon: (lm85) Let the user set the fan min limit to 0
Trying to set the fan min limit to 0 currently writes 0 to the register, which is an invalid value. It's read back as -1 and the alarm flag is raised. Instead we should write 0xffff (maximum value), which reads back as 0 and no alarm flag is raised. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r--drivers/hwmon/lm85.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 0c61fa36c83c..2ca616d7c1c0 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -145,7 +145,12 @@ static int lm85_scaling[] = { /* .001 Volts */
145#define INS_FROM_REG(n,val) SCALE((val), 192, lm85_scaling[n]) 145#define INS_FROM_REG(n,val) SCALE((val), 192, lm85_scaling[n])
146 146
147/* FAN speed is measured using 90kHz clock */ 147/* FAN speed is measured using 90kHz clock */
148#define FAN_TO_REG(val) (SENSORS_LIMIT( (val)<=0?0: 5400000/(val),0,65534)) 148static inline u16 FAN_TO_REG(unsigned long val)
149{
150 if (!val)
151 return 0xffff;
152 return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
153}
149#define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val)) 154#define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val))
150 155
151/* Temperature is reported in .001 degC increments */ 156/* Temperature is reported in .001 degC increments */
@@ -391,7 +396,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
391 int nr = to_sensor_dev_attr(attr)->index; 396 int nr = to_sensor_dev_attr(attr)->index;
392 struct i2c_client *client = to_i2c_client(dev); 397 struct i2c_client *client = to_i2c_client(dev);
393 struct lm85_data *data = i2c_get_clientdata(client); 398 struct lm85_data *data = i2c_get_clientdata(client);
394 long val = simple_strtol(buf, NULL, 10); 399 unsigned long val = simple_strtoul(buf, NULL, 10);
395 400
396 mutex_lock(&data->update_lock); 401 mutex_lock(&data->update_lock);
397 data->fan_min[nr] = FAN_TO_REG(val); 402 data->fan_min[nr] = FAN_TO_REG(val);