diff options
| author | Jean Delvare <khali@linux-fr.org> | 2010-11-15 15:38:56 -0500 |
|---|---|---|
| committer | Jean Delvare <khali@endymion.delvare> | 2010-11-15 15:38:56 -0500 |
| commit | ae51cd9bcd9ca841bf45c0ba33823c56ac1ce81e (patch) | |
| tree | bf08d6bc425c43cce063ecdb2e3e76bb776b1618 | |
| parent | 61ec2da506ec6544873f0aba026164e4bdd21751 (diff) | |
hwmon: (w83795) Fix fan control mode attributes
There were two bugs:
* Speed cruise mode was improperly reported for all fans but fan1.
* Fan control method (PWM vs. DC) was mixed with the control mode.
It will be added back as a separate attribute, as per the standard
sysfs interface.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
| -rw-r--r-- | drivers/hwmon/w83795.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index 1d840aa83782..fd96e72adde0 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
| @@ -857,20 +857,20 @@ show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) | |||
| 857 | int index = sensor_attr->index; | 857 | int index = sensor_attr->index; |
| 858 | u8 tmp; | 858 | u8 tmp; |
| 859 | 859 | ||
| 860 | if (1 == (data->pwm_fcms[0] & (1 << index))) { | 860 | /* Speed cruise mode */ |
| 861 | if (data->pwm_fcms[0] & (1 << index)) { | ||
| 861 | tmp = 2; | 862 | tmp = 2; |
| 862 | goto out; | 863 | goto out; |
| 863 | } | 864 | } |
| 865 | /* Thermal cruise or SmartFan IV mode */ | ||
| 864 | for (tmp = 0; tmp < 6; tmp++) { | 866 | for (tmp = 0; tmp < 6; tmp++) { |
| 865 | if (data->pwm_tfmr[tmp] & (1 << index)) { | 867 | if (data->pwm_tfmr[tmp] & (1 << index)) { |
| 866 | tmp = 3; | 868 | tmp = 3; |
| 867 | goto out; | 869 | goto out; |
| 868 | } | 870 | } |
| 869 | } | 871 | } |
| 870 | if (data->pwm_fomc & (1 << index)) | 872 | /* Manual mode */ |
| 871 | tmp = 0; | 873 | tmp = 1; |
| 872 | else | ||
| 873 | tmp = 1; | ||
| 874 | 874 | ||
| 875 | out: | 875 | out: |
| 876 | return sprintf(buf, "%u\n", tmp); | 876 | return sprintf(buf, "%u\n", tmp); |
| @@ -890,23 +890,21 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
| 890 | 890 | ||
| 891 | if (strict_strtoul(buf, 10, &val) < 0) | 891 | if (strict_strtoul(buf, 10, &val) < 0) |
| 892 | return -EINVAL; | 892 | return -EINVAL; |
| 893 | if (val > 2) | 893 | if (val < 1 || val > 2) |
| 894 | return -EINVAL; | 894 | return -EINVAL; |
| 895 | 895 | ||
| 896 | mutex_lock(&data->update_lock); | 896 | mutex_lock(&data->update_lock); |
| 897 | switch (val) { | 897 | switch (val) { |
| 898 | case 0: | ||
| 899 | case 1: | 898 | case 1: |
| 899 | /* Clear speed cruise mode bits */ | ||
| 900 | data->pwm_fcms[0] &= ~(1 << index); | 900 | data->pwm_fcms[0] &= ~(1 << index); |
| 901 | w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); | 901 | w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); |
| 902 | /* Clear thermal cruise mode bits */ | ||
| 902 | for (i = 0; i < 6; i++) { | 903 | for (i = 0; i < 6; i++) { |
| 903 | data->pwm_tfmr[i] &= ~(1 << index); | 904 | data->pwm_tfmr[i] &= ~(1 << index); |
| 904 | w83795_write(client, W83795_REG_TFMR(i), | 905 | w83795_write(client, W83795_REG_TFMR(i), |
| 905 | data->pwm_tfmr[i]); | 906 | data->pwm_tfmr[i]); |
| 906 | } | 907 | } |
| 907 | data->pwm_fomc |= 1 << index; | ||
| 908 | data->pwm_fomc ^= val << index; | ||
| 909 | w83795_write(client, W83795_REG_FOMC, data->pwm_fomc); | ||
| 910 | break; | 908 | break; |
| 911 | case 2: | 909 | case 2: |
| 912 | data->pwm_fcms[0] |= (1 << index); | 910 | data->pwm_fcms[0] |= (1 << index); |
