hwmon: (w83795) Expose fan control method

Expose fan control method (DC vs. PWM) using the standard sysfs
attributes. I've made it read-only as the board should be wired for
a given mode, the BIOS should have set up the chip for this mode, and
you shouldn't have to change it. But it would be easy enough to make
it changeable if someone comes up with a use case.

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 d5ab845a ae51cd9b

+18 -1
+18 -1
drivers/hwmon/w83795.c
··· 916 } 917 918 static ssize_t 919 show_temp_src(struct device *dev, struct device_attribute *attr, char *buf) 920 { 921 struct sensor_device_attribute_2 *sensor_attr = ··· 1566 show_pwm, store_pwm, PWM_FREQ, index - 1), \ 1567 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \ 1568 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \ 1569 SENSOR_ATTR_2(fan##index##_target, S_IWUSR | S_IRUGO, \ 1570 show_fanin, store_fanin, FANIN_TARGET, index - 1) } 1571 ··· 1715 SENSOR_ATTR_DTS(14), 1716 }; 1717 1718 - static const struct sensor_device_attribute_2 w83795_pwm[][7] = { 1719 SENSOR_ATTR_PWM(1), 1720 SENSOR_ATTR_PWM(2), 1721 SENSOR_ATTR_PWM(3),
··· 916 } 917 918 static ssize_t 919 + show_pwm_mode(struct device *dev, struct device_attribute *attr, char *buf) 920 + { 921 + struct w83795_data *data = w83795_update_pwm_config(dev); 922 + int index = to_sensor_dev_attr_2(attr)->index; 923 + unsigned int mode; 924 + 925 + if (data->pwm_fomc & (1 << index)) 926 + mode = 0; /* DC */ 927 + else 928 + mode = 1; /* PWM */ 929 + 930 + return sprintf(buf, "%u\n", mode); 931 + } 932 + 933 + static ssize_t 934 show_temp_src(struct device *dev, struct device_attribute *attr, char *buf) 935 { 936 struct sensor_device_attribute_2 *sensor_attr = ··· 1551 show_pwm, store_pwm, PWM_FREQ, index - 1), \ 1552 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \ 1553 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \ 1554 + SENSOR_ATTR_2(pwm##index##_mode, S_IRUGO, \ 1555 + show_pwm_mode, NULL, NOT_USED, index - 1), \ 1556 SENSOR_ATTR_2(fan##index##_target, S_IWUSR | S_IRUGO, \ 1557 show_fanin, store_fanin, FANIN_TARGET, index - 1) } 1558 ··· 1698 SENSOR_ATTR_DTS(14), 1699 }; 1700 1701 + static const struct sensor_device_attribute_2 w83795_pwm[][8] = { 1702 SENSOR_ATTR_PWM(1), 1703 SENSOR_ATTR_PWM(2), 1704 SENSOR_ATTR_PWM(3),