diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-01-12 15:55:09 -0500 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-01-12 15:55:09 -0500 |
commit | f790674d3f87df6390828ac21a7d1530f71b59c8 (patch) | |
tree | 0ecb41ffc87ec234c7dd4e62e9f835bd8265f20f /drivers/hwmon/via686a.c | |
parent | 014bcd28a04ec085940ea3125f5ea91b16a1945d (diff) |
hwmon: (via686a) Initialize fan_div values
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>
Diffstat (limited to 'drivers/hwmon/via686a.c')
-rw-r--r-- | drivers/hwmon/via686a.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 13e8d218e495..25e91665a0a2 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -689,6 +689,13 @@ static int __devexit via686a_remove(struct platform_device *pdev) | |||
689 | return 0; | 689 | return 0; |
690 | } | 690 | } |
691 | 691 | ||
692 | static void via686a_update_fan_div(struct via686a_data *data) | ||
693 | { | ||
694 | int reg = via686a_read_value(data, VIA686A_REG_FANDIV); | ||
695 | data->fan_div[0] = (reg >> 4) & 0x03; | ||
696 | data->fan_div[1] = reg >> 6; | ||
697 | } | ||
698 | |||
692 | static void __devinit via686a_init_device(struct via686a_data *data) | 699 | static void __devinit via686a_init_device(struct via686a_data *data) |
693 | { | 700 | { |
694 | u8 reg; | 701 | u8 reg; |
@@ -702,6 +709,9 @@ static void __devinit via686a_init_device(struct via686a_data *data) | |||
702 | via686a_write_value(data, VIA686A_REG_TEMP_MODE, | 709 | via686a_write_value(data, VIA686A_REG_TEMP_MODE, |
703 | (reg & ~VIA686A_TEMP_MODE_MASK) | 710 | (reg & ~VIA686A_TEMP_MODE_MASK) |
704 | | VIA686A_TEMP_MODE_CONTINUOUS); | 711 | | VIA686A_TEMP_MODE_CONTINUOUS); |
712 | |||
713 | /* Pre-read fan clock divisor values */ | ||
714 | via686a_update_fan_div(data); | ||
705 | } | 715 | } |
706 | 716 | ||
707 | static struct via686a_data *via686a_update_device(struct device *dev) | 717 | static struct via686a_data *via686a_update_device(struct device *dev) |
@@ -753,9 +763,7 @@ static struct via686a_data *via686a_update_device(struct device *dev) | |||
753 | (via686a_read_value(data, VIA686A_REG_TEMP_LOW23) & | 763 | (via686a_read_value(data, VIA686A_REG_TEMP_LOW23) & |
754 | 0xc0) >> 6; | 764 | 0xc0) >> 6; |
755 | 765 | ||
756 | i = via686a_read_value(data, VIA686A_REG_FANDIV); | 766 | via686a_update_fan_div(data); |
757 | data->fan_div[0] = (i >> 4) & 0x03; | ||
758 | data->fan_div[1] = i >> 6; | ||
759 | data->alarms = | 767 | data->alarms = |
760 | via686a_read_value(data, | 768 | via686a_read_value(data, |
761 | VIA686A_REG_ALARM1) | | 769 | VIA686A_REG_ALARM1) | |