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>

authored by Jean Delvare and committed by Jean Delvare ae51cd9b 61ec2da5

+8 -10
+8 -10
drivers/hwmon/w83795.c
··· 857 int index = sensor_attr->index; 858 u8 tmp; 859 860 - if (1 == (data->pwm_fcms[0] & (1 << index))) { 861 tmp = 2; 862 goto out; 863 } 864 for (tmp = 0; tmp < 6; tmp++) { 865 if (data->pwm_tfmr[tmp] & (1 << index)) { 866 tmp = 3; 867 goto out; 868 } 869 } 870 - if (data->pwm_fomc & (1 << index)) 871 - tmp = 0; 872 - else 873 - tmp = 1; 874 875 out: 876 return sprintf(buf, "%u\n", tmp); ··· 890 891 if (strict_strtoul(buf, 10, &val) < 0) 892 return -EINVAL; 893 - if (val > 2) 894 return -EINVAL; 895 896 mutex_lock(&data->update_lock); 897 switch (val) { 898 - case 0: 899 case 1: 900 data->pwm_fcms[0] &= ~(1 << index); 901 w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); 902 for (i = 0; i < 6; i++) { 903 data->pwm_tfmr[i] &= ~(1 << index); 904 w83795_write(client, W83795_REG_TFMR(i), 905 data->pwm_tfmr[i]); 906 } 907 - data->pwm_fomc |= 1 << index; 908 - data->pwm_fomc ^= val << index; 909 - w83795_write(client, W83795_REG_FOMC, data->pwm_fomc); 910 break; 911 case 2: 912 data->pwm_fcms[0] |= (1 << index);
··· 857 int index = sensor_attr->index; 858 u8 tmp; 859 860 + /* Speed cruise mode */ 861 + if (data->pwm_fcms[0] & (1 << index)) { 862 tmp = 2; 863 goto out; 864 } 865 + /* Thermal cruise or SmartFan IV mode */ 866 for (tmp = 0; tmp < 6; tmp++) { 867 if (data->pwm_tfmr[tmp] & (1 << index)) { 868 tmp = 3; 869 goto out; 870 } 871 } 872 + /* Manual mode */ 873 + tmp = 1; 874 875 out: 876 return sprintf(buf, "%u\n", tmp); ··· 890 891 if (strict_strtoul(buf, 10, &val) < 0) 892 return -EINVAL; 893 + if (val < 1 || val > 2) 894 return -EINVAL; 895 896 mutex_lock(&data->update_lock); 897 switch (val) { 898 case 1: 899 + /* Clear speed cruise mode bits */ 900 data->pwm_fcms[0] &= ~(1 << index); 901 w83795_write(client, W83795_REG_FCMS1, data->pwm_fcms[0]); 902 + /* Clear thermal cruise mode bits */ 903 for (i = 0; i < 6; i++) { 904 data->pwm_tfmr[i] &= ~(1 << index); 905 w83795_write(client, W83795_REG_TFMR(i), 906 data->pwm_tfmr[i]); 907 } 908 break; 909 case 2: 910 data->pwm_fcms[0] |= (1 << index);