diff options
Diffstat (limited to 'drivers/hwmon/w83795.c')
-rw-r--r-- | drivers/hwmon/w83795.c | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index ca8b0aec53e6..393f1025f6c8 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -1447,7 +1447,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1447 | 1447 | ||
1448 | #define NOT_USED -1 | 1448 | #define NOT_USED -1 |
1449 | 1449 | ||
1450 | #define SENSOR_ATTR_IN(index) \ | 1450 | #define SENSOR_ATTR_IN(index) { \ |
1451 | SENSOR_ATTR_2(in##index##_input, S_IRUGO, show_in, NULL, \ | 1451 | SENSOR_ATTR_2(in##index##_input, S_IRUGO, show_in, NULL, \ |
1452 | IN_READ, index), \ | 1452 | IN_READ, index), \ |
1453 | SENSOR_ATTR_2(in##index##_max, S_IRUGO | S_IWUSR, show_in, \ | 1453 | SENSOR_ATTR_2(in##index##_max, S_IRUGO | S_IWUSR, show_in, \ |
@@ -1458,9 +1458,9 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1458 | NULL, ALARM_STATUS, index + ((index > 14) ? 1 : 0)), \ | 1458 | NULL, ALARM_STATUS, index + ((index > 14) ? 1 : 0)), \ |
1459 | SENSOR_ATTR_2(in##index##_beep, S_IWUSR | S_IRUGO, \ | 1459 | SENSOR_ATTR_2(in##index##_beep, S_IWUSR | S_IRUGO, \ |
1460 | show_alarm_beep, store_beep, BEEP_ENABLE, \ | 1460 | show_alarm_beep, store_beep, BEEP_ENABLE, \ |
1461 | index + ((index > 14) ? 1 : 0)) | 1461 | index + ((index > 14) ? 1 : 0)) } |
1462 | 1462 | ||
1463 | #define SENSOR_ATTR_FAN(index) \ | 1463 | #define SENSOR_ATTR_FAN(index) { \ |
1464 | SENSOR_ATTR_2(fan##index##_input, S_IRUGO, show_fan, \ | 1464 | SENSOR_ATTR_2(fan##index##_input, S_IRUGO, show_fan, \ |
1465 | NULL, FAN_INPUT, index - 1), \ | 1465 | NULL, FAN_INPUT, index - 1), \ |
1466 | SENSOR_ATTR_2(fan##index##_min, S_IWUSR | S_IRUGO, \ | 1466 | SENSOR_ATTR_2(fan##index##_min, S_IWUSR | S_IRUGO, \ |
@@ -1468,7 +1468,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1468 | SENSOR_ATTR_2(fan##index##_alarm, S_IRUGO, show_alarm_beep, \ | 1468 | SENSOR_ATTR_2(fan##index##_alarm, S_IRUGO, show_alarm_beep, \ |
1469 | NULL, ALARM_STATUS, index + 31), \ | 1469 | NULL, ALARM_STATUS, index + 31), \ |
1470 | SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \ | 1470 | SENSOR_ATTR_2(fan##index##_beep, S_IWUSR | S_IRUGO, \ |
1471 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 31) | 1471 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 31) } |
1472 | 1472 | ||
1473 | #define SENSOR_ATTR_PWM(index) \ | 1473 | #define SENSOR_ATTR_PWM(index) \ |
1474 | SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ | 1474 | SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ |
@@ -1488,7 +1488,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1488 | SENSOR_ATTR_2(speed_cruise##index##_target, S_IWUSR | S_IRUGO, \ | 1488 | SENSOR_ATTR_2(speed_cruise##index##_target, S_IWUSR | S_IRUGO, \ |
1489 | show_fanin, store_fanin, FANIN_TARGET, index - 1) | 1489 | show_fanin, store_fanin, FANIN_TARGET, index - 1) |
1490 | 1490 | ||
1491 | #define SENSOR_ATTR_DTS(index) \ | 1491 | #define SENSOR_ATTR_DTS(index) { \ |
1492 | SENSOR_ATTR_2(temp##index##_type, S_IRUGO , \ | 1492 | SENSOR_ATTR_2(temp##index##_type, S_IRUGO , \ |
1493 | show_dts_mode, NULL, NOT_USED, index - 7), \ | 1493 | show_dts_mode, NULL, NOT_USED, index - 7), \ |
1494 | SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_dts, \ | 1494 | SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_dts, \ |
@@ -1504,9 +1504,9 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1504 | SENSOR_ATTR_2(temp##index##_alarm, S_IRUGO, \ | 1504 | SENSOR_ATTR_2(temp##index##_alarm, S_IRUGO, \ |
1505 | show_alarm_beep, NULL, ALARM_STATUS, index + 17), \ | 1505 | show_alarm_beep, NULL, ALARM_STATUS, index + 17), \ |
1506 | SENSOR_ATTR_2(temp##index##_beep, S_IWUSR | S_IRUGO, \ | 1506 | SENSOR_ATTR_2(temp##index##_beep, S_IWUSR | S_IRUGO, \ |
1507 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 17) | 1507 | show_alarm_beep, store_beep, BEEP_ENABLE, index + 17) } |
1508 | 1508 | ||
1509 | #define SENSOR_ATTR_TEMP(index) \ | 1509 | #define SENSOR_ATTR_TEMP(index) { \ |
1510 | SENSOR_ATTR_2(temp##index##_type, S_IRUGO | S_IWUSR, \ | 1510 | SENSOR_ATTR_2(temp##index##_type, S_IRUGO | S_IWUSR, \ |
1511 | show_temp_mode, store_temp_mode, NOT_USED, index - 1), \ | 1511 | show_temp_mode, store_temp_mode, NOT_USED, index - 1), \ |
1512 | SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_temp, \ | 1512 | SENSOR_ATTR_2(temp##index##_input, S_IRUGO, show_temp, \ |
@@ -1568,10 +1568,10 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1568 | SENSOR_ATTR_2(temp##index##_auto_point6_temp, S_IRUGO | S_IWUSR,\ | 1568 | SENSOR_ATTR_2(temp##index##_auto_point6_temp, S_IRUGO | S_IWUSR,\ |
1569 | show_sf4_temp, store_sf4_temp, 5, index - 1), \ | 1569 | show_sf4_temp, store_sf4_temp, 5, index - 1), \ |
1570 | SENSOR_ATTR_2(temp##index##_auto_point7_temp, S_IRUGO | S_IWUSR,\ | 1570 | SENSOR_ATTR_2(temp##index##_auto_point7_temp, S_IRUGO | S_IWUSR,\ |
1571 | show_sf4_temp, store_sf4_temp, 6, index - 1) | 1571 | show_sf4_temp, store_sf4_temp, 6, index - 1) } |
1572 | 1572 | ||
1573 | 1573 | ||
1574 | static struct sensor_device_attribute_2 w83795_in[] = { | 1574 | static struct sensor_device_attribute_2 w83795_in[][5] = { |
1575 | SENSOR_ATTR_IN(0), | 1575 | SENSOR_ATTR_IN(0), |
1576 | SENSOR_ATTR_IN(1), | 1576 | SENSOR_ATTR_IN(1), |
1577 | SENSOR_ATTR_IN(2), | 1577 | SENSOR_ATTR_IN(2), |
@@ -1595,7 +1595,7 @@ static struct sensor_device_attribute_2 w83795_in[] = { | |||
1595 | SENSOR_ATTR_IN(20), | 1595 | SENSOR_ATTR_IN(20), |
1596 | }; | 1596 | }; |
1597 | 1597 | ||
1598 | static struct sensor_device_attribute_2 w83795_fan[] = { | 1598 | static struct sensor_device_attribute_2 w83795_fan[][4] = { |
1599 | SENSOR_ATTR_FAN(1), | 1599 | SENSOR_ATTR_FAN(1), |
1600 | SENSOR_ATTR_FAN(2), | 1600 | SENSOR_ATTR_FAN(2), |
1601 | SENSOR_ATTR_FAN(3), | 1601 | SENSOR_ATTR_FAN(3), |
@@ -1612,7 +1612,7 @@ static struct sensor_device_attribute_2 w83795_fan[] = { | |||
1612 | SENSOR_ATTR_FAN(14), | 1612 | SENSOR_ATTR_FAN(14), |
1613 | }; | 1613 | }; |
1614 | 1614 | ||
1615 | static struct sensor_device_attribute_2 w83795_temp[] = { | 1615 | static struct sensor_device_attribute_2 w83795_temp[][29] = { |
1616 | SENSOR_ATTR_TEMP(1), | 1616 | SENSOR_ATTR_TEMP(1), |
1617 | SENSOR_ATTR_TEMP(2), | 1617 | SENSOR_ATTR_TEMP(2), |
1618 | SENSOR_ATTR_TEMP(3), | 1618 | SENSOR_ATTR_TEMP(3), |
@@ -1621,7 +1621,7 @@ static struct sensor_device_attribute_2 w83795_temp[] = { | |||
1621 | SENSOR_ATTR_TEMP(6), | 1621 | SENSOR_ATTR_TEMP(6), |
1622 | }; | 1622 | }; |
1623 | 1623 | ||
1624 | static struct sensor_device_attribute_2 w83795_dts[] = { | 1624 | static struct sensor_device_attribute_2 w83795_dts[][8] = { |
1625 | SENSOR_ATTR_DTS(7), | 1625 | SENSOR_ATTR_DTS(7), |
1626 | SENSOR_ATTR_DTS(8), | 1626 | SENSOR_ATTR_DTS(8), |
1627 | SENSOR_ATTR_DTS(9), | 1627 | SENSOR_ATTR_DTS(9), |
@@ -1781,22 +1781,26 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *, | |||
1781 | const struct device_attribute *)) | 1781 | const struct device_attribute *)) |
1782 | { | 1782 | { |
1783 | struct w83795_data *data = dev_get_drvdata(dev); | 1783 | struct w83795_data *data = dev_get_drvdata(dev); |
1784 | int err, i; | 1784 | int err, i, j; |
1785 | 1785 | ||
1786 | for (i = 0; i < ARRAY_SIZE(w83795_in); i++) { | 1786 | for (i = 0; i < ARRAY_SIZE(w83795_in); i++) { |
1787 | if (!(data->has_in & (1 << (i / 6)))) | 1787 | if (!(data->has_in & (1 << i))) |
1788 | continue; | 1788 | continue; |
1789 | err = fn(dev, &w83795_in[i].dev_attr); | 1789 | for (j = 0; j < ARRAY_SIZE(w83795_in[0]); j++) { |
1790 | if (err) | 1790 | err = fn(dev, &w83795_in[i][j].dev_attr); |
1791 | return err; | 1791 | if (err) |
1792 | return err; | ||
1793 | } | ||
1792 | } | 1794 | } |
1793 | 1795 | ||
1794 | for (i = 0; i < ARRAY_SIZE(w83795_fan); i++) { | 1796 | for (i = 0; i < ARRAY_SIZE(w83795_fan); i++) { |
1795 | if (!(data->has_fan & (1 << (i / 5)))) | 1797 | if (!(data->has_fan & (1 << i))) |
1796 | continue; | 1798 | continue; |
1797 | err = fn(dev, &w83795_fan[i].dev_attr); | 1799 | for (j = 0; j < ARRAY_SIZE(w83795_fan[0]); j++) { |
1798 | if (err) | 1800 | err = fn(dev, &w83795_fan[i][j].dev_attr); |
1799 | return err; | 1801 | if (err) |
1802 | return err; | ||
1803 | } | ||
1800 | } | 1804 | } |
1801 | 1805 | ||
1802 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { | 1806 | for (i = 0; i < ARRAY_SIZE(sda_single_files); i++) { |
@@ -1814,20 +1818,24 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *, | |||
1814 | } | 1818 | } |
1815 | 1819 | ||
1816 | for (i = 0; i < ARRAY_SIZE(w83795_temp); i++) { | 1820 | for (i = 0; i < ARRAY_SIZE(w83795_temp); i++) { |
1817 | if (!(data->has_temp & (1 << (i / 29)))) | 1821 | if (!(data->has_temp & (1 << i))) |
1818 | continue; | 1822 | continue; |
1819 | err = fn(dev, &w83795_temp[i].dev_attr); | 1823 | for (j = 0; j < ARRAY_SIZE(w83795_temp[0]); j++) { |
1820 | if (err) | 1824 | err = fn(dev, &w83795_temp[i][j].dev_attr); |
1821 | return err; | 1825 | if (err) |
1826 | return err; | ||
1827 | } | ||
1822 | } | 1828 | } |
1823 | 1829 | ||
1824 | if (data->enable_dts != 0) { | 1830 | if (data->enable_dts != 0) { |
1825 | for (i = 0; i < ARRAY_SIZE(w83795_dts); i++) { | 1831 | for (i = 0; i < ARRAY_SIZE(w83795_dts); i++) { |
1826 | if (!(data->has_dts & (1 << (i / 8)))) | 1832 | if (!(data->has_dts & (1 << i))) |
1827 | continue; | 1833 | continue; |
1828 | err = fn(dev, &w83795_dts[i].dev_attr); | 1834 | for (j = 0; j < ARRAY_SIZE(w83795_dts[0]); j++) { |
1829 | if (err) | 1835 | err = fn(dev, &w83795_dts[i][j].dev_attr); |
1830 | return err; | 1836 | if (err) |
1837 | return err; | ||
1838 | } | ||
1831 | } | 1839 | } |
1832 | } | 1840 | } |
1833 | 1841 | ||