Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=38a1f0e9aed014be66c474ecd9fe8513646de833
Commit:     38a1f0e9aed014be66c474ecd9fe8513646de833
Parent:     d5b0b5d62823f08ab4988e1b179fd5a9bddced31
Author:     Jean Delvare <[EMAIL PROTECTED]>
AuthorDate: Sun Dec 2 23:32:42 2007 +0100
Committer:  Mark M. Hoffman <[EMAIL PROTECTED]>
CommitDate: Thu Feb 7 20:39:43 2008 -0500

    hwmon: (adm1031) Fix register overwrite in set_fan_div()
    
    Don't rely on the register cache when setting a new fan clock divider.
    For one thing, the cache might not have been initialized at all if the
    driver has just been loaded. For another, the cached values may be old
    and you never know what can happen in the driver's back.
    
    Also invalidate the cache instead of trying to adjust the measured fan
    speed: the whole point of changing the clock divider is to get a better
    reading.
    
    Signed-off-by: Jean Delvare <[EMAIL PROTECTED]>
    Signed-off-by: Mark M. Hoffman <[EMAIL PROTECTED]>
---
 drivers/hwmon/adm1031.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index 37cfc10..558d83b 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -542,18 +542,26 @@ set_fan_div(struct device *dev, const char *buf, size_t 
count, int nr)
                return -EINVAL;
        
        mutex_lock(&data->update_lock);
+       /* Get fresh readings */
+       data->fan_div[nr] = adm1031_read_value(client,
+                                              ADM1031_REG_FAN_DIV(nr));
+       data->fan_min[nr] = adm1031_read_value(client,
+                                              ADM1031_REG_FAN_MIN(nr));
+
+       /* Write the new clock divider and fan min */
        old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
        data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]);
        new_min = data->fan_min[nr] * old_div / 
                FAN_DIV_FROM_REG(data->fan_div[nr]);
        data->fan_min[nr] = new_min > 0xff ? 0xff : new_min;
-       data->fan[nr] = data->fan[nr] * old_div / 
-               FAN_DIV_FROM_REG(data->fan_div[nr]);
 
        adm1031_write_value(client, ADM1031_REG_FAN_DIV(nr), 
                            data->fan_div[nr]);
        adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), 
                            data->fan_min[nr]);
+
+       /* Invalidate the cache: fan speed is no longer valid */
+       data->valid = 0;
        mutex_unlock(&data->update_lock);
        return count;
 }
-
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