Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=63f281a6e32ebc93c62dac0d399d8e054eb7b2ec
Commit:     63f281a6e32ebc93c62dac0d399d8e054eb7b2ec
Parent:     5a4d3ef317c845893fe3f9d3517cb0a99375da53
Author:     Jean Delvare <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 5 20:39:40 2007 +0200
Committer:  Mark M. Hoffman <[EMAIL PROTECTED]>
CommitDate: Tue Oct 9 22:56:30 2007 -0400

    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 <[EMAIL PROTECTED]>
    Acked-by: Juerg Haefliger <juergh at gmail.com>
    Signed-off-by: Mark M. Hoffman <[EMAIL PROTECTED]>
---
 drivers/hwmon/lm85.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 0c61fa3..2ca616d 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -145,7 +145,12 @@ static int lm85_scaling[] = {  /* .001 Volts */
 #define INS_FROM_REG(n,val)    SCALE((val), 192, lm85_scaling[n])
 
 /* FAN speed is measured using 90kHz clock */
-#define FAN_TO_REG(val)                (SENSORS_LIMIT( (val)<=0?0: 
5400000/(val),0,65534))
+static inline u16 FAN_TO_REG(unsigned long val)
+{
+       if (!val)
+               return 0xffff;
+       return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
+}
 #define FAN_FROM_REG(val)      ((val)==0?-1:(val)==0xffff?0:5400000/(val))
 
 /* Temperature is reported in .001 degC increments */
@@ -391,7 +396,7 @@ static ssize_t set_fan_min(struct device *dev, struct 
device_attribute *attr,
        int nr = to_sensor_dev_attr(attr)->index;
        struct i2c_client *client = to_i2c_client(dev);
        struct lm85_data *data = i2c_get_clientdata(client);
-       long val = simple_strtol(buf, NULL, 10);
+       unsigned long val = simple_strtoul(buf, NULL, 10);
 
        mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to