]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
hwmon: (via686a) Initialize fan_div values
authorJean Delvare <khali@linux-fr.org>
Wed, 12 Jan 2011 20:55:09 +0000 (21:55 +0100)
committerJean Delvare <khali@endymion.delvare>
Wed, 12 Jan 2011 20:55:09 +0000 (21:55 +0100)
Functions set_fan_min() and set_fan_div() assume that the fan_div
values have already been read from the register. The driver currently
doesn't initialize them at load time, they are only set when function
via686a_update_device() is called. This means that set_fan_min() and
set_fan_div() misbehave if, for example, "sensors -s" is called
before any monitoring application (e.g. "sensors") is has been run.

Fix the problem by always initializing the fan_div values at device
bind time.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: stable@kernel.org
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
drivers/hwmon/via686a.c

index 13e8d218e49542ff87dd91a915b961239aa5195d..25e91665a0a2e5ef3223fe2ae5143fab4180593e 100644 (file)
@@ -689,6 +689,13 @@ static int __devexit via686a_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void via686a_update_fan_div(struct via686a_data *data)
+{
+       int reg = via686a_read_value(data, VIA686A_REG_FANDIV);
+       data->fan_div[0] = (reg >> 4) & 0x03;
+       data->fan_div[1] = reg >> 6;
+}
+
 static void __devinit via686a_init_device(struct via686a_data *data)
 {
        u8 reg;
@@ -702,6 +709,9 @@ static void __devinit via686a_init_device(struct via686a_data *data)
        via686a_write_value(data, VIA686A_REG_TEMP_MODE,
                            (reg & ~VIA686A_TEMP_MODE_MASK)
                            | VIA686A_TEMP_MODE_CONTINUOUS);
+
+       /* Pre-read fan clock divisor values */
+       via686a_update_fan_div(data);
 }
 
 static struct via686a_data *via686a_update_device(struct device *dev)
@@ -753,9 +763,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
                    (via686a_read_value(data, VIA686A_REG_TEMP_LOW23) &
                     0xc0) >> 6;
 
-               i = via686a_read_value(data, VIA686A_REG_FANDIV);
-               data->fan_div[0] = (i >> 4) & 0x03;
-               data->fan_div[1] = i >> 6;
+               via686a_update_fan_div(data);
                data->alarms =
                    via686a_read_value(data,
                                       VIA686A_REG_ALARM1) |