diff options
-rw-r--r-- | drivers/hwmon/it87.c | 263 |
1 files changed, 104 insertions, 159 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 76756326918..e0d1910c04d 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -262,8 +262,7 @@ struct it87_data { | |||
262 | u16 in_scaled; /* Internal voltage sensors are scaled */ | 262 | u16 in_scaled; /* Internal voltage sensors are scaled */ |
263 | u8 in[9][3]; /* [nr][0]=in, [1]=min, [2]=max */ | 263 | u8 in[9][3]; /* [nr][0]=in, [1]=min, [2]=max */ |
264 | u8 has_fan; /* Bitfield, fans enabled */ | 264 | u8 has_fan; /* Bitfield, fans enabled */ |
265 | u16 fan[5]; /* Register values, possibly combined */ | 265 | u16 fan[5][2]; /* Register values, [nr][0]=fan, [1]=min */ |
266 | u16 fan_min[5]; /* Register values, possibly combined */ | ||
267 | u8 has_temp; /* Bitfield, temp sensors enabled */ | 266 | u8 has_temp; /* Bitfield, temp sensors enabled */ |
268 | s8 temp[3][4]; /* [nr][0]=temp, [1]=min, [2]=max, [3]=offset */ | 267 | s8 temp[3][4]; /* [nr][0]=temp, [1]=min, [2]=max, [3]=offset */ |
269 | u8 sensor; /* Register value */ | 268 | u8 sensor; /* Register value */ |
@@ -687,25 +686,21 @@ static int pwm_mode(const struct it87_data *data, int nr) | |||
687 | } | 686 | } |
688 | 687 | ||
689 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, | 688 | static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
690 | char *buf) | 689 | char *buf) |
691 | { | 690 | { |
692 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 691 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
693 | int nr = sensor_attr->index; | 692 | int nr = sattr->nr; |
694 | 693 | int index = sattr->index; | |
694 | int speed; | ||
695 | struct it87_data *data = it87_update_device(dev); | 695 | struct it87_data *data = it87_update_device(dev); |
696 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | ||
697 | DIV_FROM_REG(data->fan_div[nr]))); | ||
698 | } | ||
699 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | ||
700 | char *buf) | ||
701 | { | ||
702 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
703 | int nr = sensor_attr->index; | ||
704 | 696 | ||
705 | struct it87_data *data = it87_update_device(dev); | 697 | speed = has_16bit_fans(data) ? |
706 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 698 | FAN16_FROM_REG(data->fan[nr][index]) : |
707 | DIV_FROM_REG(data->fan_div[nr]))); | 699 | FAN_FROM_REG(data->fan[nr][index], |
700 | DIV_FROM_REG(data->fan_div[nr])); | ||
701 | return sprintf(buf, "%d\n", speed); | ||
708 | } | 702 | } |
703 | |||
709 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, | 704 | static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
710 | char *buf) | 705 | char *buf) |
711 | { | 706 | { |
@@ -742,11 +737,13 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr, | |||
742 | 737 | ||
743 | return sprintf(buf, "%u\n", pwm_freq[index]); | 738 | return sprintf(buf, "%u\n", pwm_freq[index]); |
744 | } | 739 | } |
745 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | 740 | |
746 | const char *buf, size_t count) | 741 | static ssize_t set_fan(struct device *dev, struct device_attribute *attr, |
742 | const char *buf, size_t count) | ||
747 | { | 743 | { |
748 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 744 | struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); |
749 | int nr = sensor_attr->index; | 745 | int nr = sattr->nr; |
746 | int index = sattr->index; | ||
750 | 747 | ||
751 | struct it87_data *data = dev_get_drvdata(dev); | 748 | struct it87_data *data = dev_get_drvdata(dev); |
752 | long val; | 749 | long val; |
@@ -756,24 +753,36 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
756 | return -EINVAL; | 753 | return -EINVAL; |
757 | 754 | ||
758 | mutex_lock(&data->update_lock); | 755 | mutex_lock(&data->update_lock); |
759 | reg = it87_read_value(data, IT87_REG_FAN_DIV); | 756 | |
760 | switch (nr) { | 757 | if (has_16bit_fans(data)) { |
761 | case 0: | 758 | data->fan[nr][index] = FAN16_TO_REG(val); |
762 | data->fan_div[nr] = reg & 0x07; | 759 | it87_write_value(data, IT87_REG_FAN_MIN[nr], |
763 | break; | 760 | data->fan[nr][index] & 0xff); |
764 | case 1: | 761 | it87_write_value(data, IT87_REG_FANX_MIN[nr], |
765 | data->fan_div[nr] = (reg >> 3) & 0x07; | 762 | data->fan[nr][index] >> 8); |
766 | break; | 763 | } else { |
767 | case 2: | 764 | reg = it87_read_value(data, IT87_REG_FAN_DIV); |
768 | data->fan_div[nr] = (reg & 0x40) ? 3 : 1; | 765 | switch (nr) { |
769 | break; | 766 | case 0: |
767 | data->fan_div[nr] = reg & 0x07; | ||
768 | break; | ||
769 | case 1: | ||
770 | data->fan_div[nr] = (reg >> 3) & 0x07; | ||
771 | break; | ||
772 | case 2: | ||
773 | data->fan_div[nr] = (reg & 0x40) ? 3 : 1; | ||
774 | break; | ||
775 | } | ||
776 | data->fan[nr][index] = | ||
777 | FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | ||
778 | it87_write_value(data, IT87_REG_FAN_MIN[nr], | ||
779 | data->fan[nr][index]); | ||
770 | } | 780 | } |
771 | 781 | ||
772 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | ||
773 | it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan_min[nr]); | ||
774 | mutex_unlock(&data->update_lock); | 782 | mutex_unlock(&data->update_lock); |
775 | return count; | 783 | return count; |
776 | } | 784 | } |
785 | |||
777 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 786 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
778 | const char *buf, size_t count) | 787 | const char *buf, size_t count) |
779 | { | 788 | { |
@@ -792,7 +801,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
792 | old = it87_read_value(data, IT87_REG_FAN_DIV); | 801 | old = it87_read_value(data, IT87_REG_FAN_DIV); |
793 | 802 | ||
794 | /* Save fan min limit */ | 803 | /* Save fan min limit */ |
795 | min = FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])); | 804 | min = FAN_FROM_REG(data->fan[nr][1], DIV_FROM_REG(data->fan_div[nr])); |
796 | 805 | ||
797 | switch (nr) { | 806 | switch (nr) { |
798 | case 0: | 807 | case 0: |
@@ -813,8 +822,8 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
813 | it87_write_value(data, IT87_REG_FAN_DIV, val); | 822 | it87_write_value(data, IT87_REG_FAN_DIV, val); |
814 | 823 | ||
815 | /* Restore fan min limit */ | 824 | /* Restore fan min limit */ |
816 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 825 | data->fan[nr][1] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
817 | it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan_min[nr]); | 826 | it87_write_value(data, IT87_REG_FAN_MIN[nr], data->fan[nr][1]); |
818 | 827 | ||
819 | mutex_unlock(&data->update_lock); | 828 | mutex_unlock(&data->update_lock); |
820 | return count; | 829 | return count; |
@@ -1087,17 +1096,31 @@ static ssize_t set_auto_temp(struct device *dev, | |||
1087 | return count; | 1096 | return count; |
1088 | } | 1097 | } |
1089 | 1098 | ||
1090 | #define show_fan_offset(offset) \ | 1099 | static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0); |
1091 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | 1100 | static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_fan, set_fan, |
1092 | show_fan, NULL, offset - 1); \ | 1101 | 0, 1); |
1093 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 1102 | static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, show_fan_div, |
1094 | show_fan_min, set_fan_min, offset - 1); \ | 1103 | set_fan_div, 0); |
1095 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 1104 | |
1096 | show_fan_div, set_fan_div, offset - 1); | 1105 | static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 1, 0); |
1106 | static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_fan, set_fan, | ||
1107 | 1, 1); | ||
1108 | static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, show_fan_div, | ||
1109 | set_fan_div, 1); | ||
1110 | |||
1111 | static SENSOR_DEVICE_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 2, 0); | ||
1112 | static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_fan, set_fan, | ||
1113 | 2, 1); | ||
1114 | static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO | S_IWUSR, show_fan_div, | ||
1115 | set_fan_div, 2); | ||
1116 | |||
1117 | static SENSOR_DEVICE_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 3, 0); | ||
1118 | static SENSOR_DEVICE_ATTR_2(fan4_min, S_IRUGO | S_IWUSR, show_fan, set_fan, | ||
1119 | 3, 1); | ||
1097 | 1120 | ||
1098 | show_fan_offset(1); | 1121 | static SENSOR_DEVICE_ATTR_2(fan5_input, S_IRUGO, show_fan, NULL, 4, 0); |
1099 | show_fan_offset(2); | 1122 | static SENSOR_DEVICE_ATTR_2(fan5_min, S_IRUGO | S_IWUSR, show_fan, set_fan, |
1100 | show_fan_offset(3); | 1123 | 4, 1); |
1101 | 1124 | ||
1102 | #define show_pwm_offset(offset) \ | 1125 | #define show_pwm_offset(offset) \ |
1103 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ | 1126 | static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
@@ -1141,65 +1164,6 @@ show_pwm_offset(1); | |||
1141 | show_pwm_offset(2); | 1164 | show_pwm_offset(2); |
1142 | show_pwm_offset(3); | 1165 | show_pwm_offset(3); |
1143 | 1166 | ||
1144 | /* A different set of callbacks for 16-bit fans */ | ||
1145 | static ssize_t show_fan16(struct device *dev, struct device_attribute *attr, | ||
1146 | char *buf) | ||
1147 | { | ||
1148 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1149 | int nr = sensor_attr->index; | ||
1150 | struct it87_data *data = it87_update_device(dev); | ||
1151 | return sprintf(buf, "%d\n", FAN16_FROM_REG(data->fan[nr])); | ||
1152 | } | ||
1153 | |||
1154 | static ssize_t show_fan16_min(struct device *dev, struct device_attribute *attr, | ||
1155 | char *buf) | ||
1156 | { | ||
1157 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1158 | int nr = sensor_attr->index; | ||
1159 | struct it87_data *data = it87_update_device(dev); | ||
1160 | return sprintf(buf, "%d\n", FAN16_FROM_REG(data->fan_min[nr])); | ||
1161 | } | ||
1162 | |||
1163 | static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr, | ||
1164 | const char *buf, size_t count) | ||
1165 | { | ||
1166 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | ||
1167 | int nr = sensor_attr->index; | ||
1168 | struct it87_data *data = dev_get_drvdata(dev); | ||
1169 | long val; | ||
1170 | |||
1171 | if (kstrtol(buf, 10, &val) < 0) | ||
1172 | return -EINVAL; | ||
1173 | |||
1174 | mutex_lock(&data->update_lock); | ||
1175 | data->fan_min[nr] = FAN16_TO_REG(val); | ||
1176 | it87_write_value(data, IT87_REG_FAN_MIN[nr], | ||
1177 | data->fan_min[nr] & 0xff); | ||
1178 | it87_write_value(data, IT87_REG_FANX_MIN[nr], | ||
1179 | data->fan_min[nr] >> 8); | ||
1180 | mutex_unlock(&data->update_lock); | ||
1181 | return count; | ||
1182 | } | ||
1183 | |||
1184 | /* | ||
1185 | * We want to use the same sysfs file names as 8-bit fans, but we need | ||
1186 | * different variable names, so we have to use SENSOR_ATTR instead of | ||
1187 | * SENSOR_DEVICE_ATTR. | ||
1188 | */ | ||
1189 | #define show_fan16_offset(offset) \ | ||
1190 | static struct sensor_device_attribute sensor_dev_attr_fan##offset##_input16 \ | ||
1191 | = SENSOR_ATTR(fan##offset##_input, S_IRUGO, \ | ||
1192 | show_fan16, NULL, offset - 1); \ | ||
1193 | static struct sensor_device_attribute sensor_dev_attr_fan##offset##_min16 \ | ||
1194 | = SENSOR_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
1195 | show_fan16_min, set_fan16_min, offset - 1) | ||
1196 | |||
1197 | show_fan16_offset(1); | ||
1198 | show_fan16_offset(2); | ||
1199 | show_fan16_offset(3); | ||
1200 | show_fan16_offset(4); | ||
1201 | show_fan16_offset(5); | ||
1202 | |||
1203 | /* Alarms */ | 1167 | /* Alarms */ |
1204 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, | 1168 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, |
1205 | char *buf) | 1169 | char *buf) |
@@ -1501,73 +1465,47 @@ static struct attribute *it87_attributes_temp_beep[] = { | |||
1501 | &sensor_dev_attr_temp3_beep.dev_attr.attr, | 1465 | &sensor_dev_attr_temp3_beep.dev_attr.attr, |
1502 | }; | 1466 | }; |
1503 | 1467 | ||
1504 | static struct attribute *it87_attributes_fan16[5][3+1] = { { | 1468 | static struct attribute *it87_attributes_fan[5][3+1] = { { |
1505 | &sensor_dev_attr_fan1_input16.dev_attr.attr, | 1469 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
1506 | &sensor_dev_attr_fan1_min16.dev_attr.attr, | 1470 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
1507 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | 1471 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
1508 | NULL | 1472 | NULL |
1509 | }, { | 1473 | }, { |
1510 | &sensor_dev_attr_fan2_input16.dev_attr.attr, | 1474 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
1511 | &sensor_dev_attr_fan2_min16.dev_attr.attr, | 1475 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
1512 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | 1476 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
1513 | NULL | 1477 | NULL |
1514 | }, { | 1478 | }, { |
1515 | &sensor_dev_attr_fan3_input16.dev_attr.attr, | 1479 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
1516 | &sensor_dev_attr_fan3_min16.dev_attr.attr, | 1480 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
1517 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | 1481 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
1518 | NULL | 1482 | NULL |
1519 | }, { | 1483 | }, { |
1520 | &sensor_dev_attr_fan4_input16.dev_attr.attr, | 1484 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
1521 | &sensor_dev_attr_fan4_min16.dev_attr.attr, | 1485 | &sensor_dev_attr_fan4_min.dev_attr.attr, |
1522 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | 1486 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, |
1523 | NULL | 1487 | NULL |
1524 | }, { | 1488 | }, { |
1525 | &sensor_dev_attr_fan5_input16.dev_attr.attr, | 1489 | &sensor_dev_attr_fan5_input.dev_attr.attr, |
1526 | &sensor_dev_attr_fan5_min16.dev_attr.attr, | 1490 | &sensor_dev_attr_fan5_min.dev_attr.attr, |
1527 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | 1491 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, |
1528 | NULL | 1492 | NULL |
1529 | } }; | 1493 | } }; |
1530 | 1494 | ||
1531 | static const struct attribute_group it87_group_fan16[5] = { | 1495 | static const struct attribute_group it87_group_fan[5] = { |
1532 | { .attrs = it87_attributes_fan16[0] }, | 1496 | { .attrs = it87_attributes_fan[0] }, |
1533 | { .attrs = it87_attributes_fan16[1] }, | 1497 | { .attrs = it87_attributes_fan[1] }, |
1534 | { .attrs = it87_attributes_fan16[2] }, | 1498 | { .attrs = it87_attributes_fan[2] }, |
1535 | { .attrs = it87_attributes_fan16[3] }, | 1499 | { .attrs = it87_attributes_fan[3] }, |
1536 | { .attrs = it87_attributes_fan16[4] }, | 1500 | { .attrs = it87_attributes_fan[4] }, |
1537 | }; | 1501 | }; |
1538 | 1502 | ||
1539 | static struct attribute *it87_attributes_fan[3][4+1] = { { | 1503 | static const struct attribute *it87_attributes_fan_div[] = { |
1540 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
1541 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1542 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 1504 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
1543 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
1544 | NULL | ||
1545 | }, { | ||
1546 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
1547 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
1548 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 1505 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
1549 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
1550 | NULL | ||
1551 | }, { | ||
1552 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
1553 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
1554 | &sensor_dev_attr_fan3_div.dev_attr.attr, | 1506 | &sensor_dev_attr_fan3_div.dev_attr.attr, |
1555 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1556 | NULL | ||
1557 | } }; | ||
1558 | |||
1559 | static const struct attribute_group it87_group_fan[3] = { | ||
1560 | { .attrs = it87_attributes_fan[0] }, | ||
1561 | { .attrs = it87_attributes_fan[1] }, | ||
1562 | { .attrs = it87_attributes_fan[2] }, | ||
1563 | }; | 1507 | }; |
1564 | 1508 | ||
1565 | static const struct attribute_group * | ||
1566 | it87_get_fan_group(const struct it87_data *data) | ||
1567 | { | ||
1568 | return has_16bit_fans(data) ? it87_group_fan16 : it87_group_fan; | ||
1569 | } | ||
1570 | |||
1571 | static struct attribute *it87_attributes_pwm[3][4+1] = { { | 1509 | static struct attribute *it87_attributes_pwm[3][4+1] = { { |
1572 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 1510 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
1573 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1511 | &sensor_dev_attr_pwm1.dev_attr.attr, |
@@ -1926,7 +1864,6 @@ static void it87_remove_files(struct device *dev) | |||
1926 | { | 1864 | { |
1927 | struct it87_data *data = platform_get_drvdata(pdev); | 1865 | struct it87_data *data = platform_get_drvdata(pdev); |
1928 | struct it87_sio_data *sio_data = dev->platform_data; | 1866 | struct it87_sio_data *sio_data = dev->platform_data; |
1929 | const struct attribute_group *fan_group = it87_get_fan_group(data); | ||
1930 | int i; | 1867 | int i; |
1931 | 1868 | ||
1932 | sysfs_remove_group(&dev->kobj, &it87_group); | 1869 | sysfs_remove_group(&dev->kobj, &it87_group); |
@@ -1952,10 +1889,13 @@ static void it87_remove_files(struct device *dev) | |||
1952 | for (i = 0; i < 5; i++) { | 1889 | for (i = 0; i < 5; i++) { |
1953 | if (!(data->has_fan & (1 << i))) | 1890 | if (!(data->has_fan & (1 << i))) |
1954 | continue; | 1891 | continue; |
1955 | sysfs_remove_group(&dev->kobj, &fan_group[i]); | 1892 | sysfs_remove_group(&dev->kobj, &it87_group_fan[i]); |
1956 | if (sio_data->beep_pin) | 1893 | if (sio_data->beep_pin) |
1957 | sysfs_remove_file(&dev->kobj, | 1894 | sysfs_remove_file(&dev->kobj, |
1958 | it87_attributes_fan_beep[i]); | 1895 | it87_attributes_fan_beep[i]); |
1896 | if (i < 3 && !has_16bit_fans(data)) | ||
1897 | sysfs_remove_file(&dev->kobj, | ||
1898 | it87_attributes_fan_div[i]); | ||
1959 | } | 1899 | } |
1960 | for (i = 0; i < 3; i++) { | 1900 | for (i = 0; i < 3; i++) { |
1961 | if (sio_data->skip_pwm & (1 << 0)) | 1901 | if (sio_data->skip_pwm & (1 << 0)) |
@@ -1976,7 +1916,6 @@ static int it87_probe(struct platform_device *pdev) | |||
1976 | struct resource *res; | 1916 | struct resource *res; |
1977 | struct device *dev = &pdev->dev; | 1917 | struct device *dev = &pdev->dev; |
1978 | struct it87_sio_data *sio_data = dev->platform_data; | 1918 | struct it87_sio_data *sio_data = dev->platform_data; |
1979 | const struct attribute_group *fan_group; | ||
1980 | int err = 0, i; | 1919 | int err = 0, i; |
1981 | int enable_pwm_interface; | 1920 | int enable_pwm_interface; |
1982 | int fan_beep_need_rw; | 1921 | int fan_beep_need_rw; |
@@ -2087,15 +2026,21 @@ static int it87_probe(struct platform_device *pdev) | |||
2087 | } | 2026 | } |
2088 | 2027 | ||
2089 | /* Do not create fan files for disabled fans */ | 2028 | /* Do not create fan files for disabled fans */ |
2090 | fan_group = it87_get_fan_group(data); | ||
2091 | fan_beep_need_rw = 1; | 2029 | fan_beep_need_rw = 1; |
2092 | for (i = 0; i < 5; i++) { | 2030 | for (i = 0; i < 5; i++) { |
2093 | if (!(data->has_fan & (1 << i))) | 2031 | if (!(data->has_fan & (1 << i))) |
2094 | continue; | 2032 | continue; |
2095 | err = sysfs_create_group(&dev->kobj, &fan_group[i]); | 2033 | err = sysfs_create_group(&dev->kobj, &it87_group_fan[i]); |
2096 | if (err) | 2034 | if (err) |
2097 | goto error; | 2035 | goto error; |
2098 | 2036 | ||
2037 | if (i < 3 && !has_16bit_fans(data)) { | ||
2038 | err = sysfs_create_file(&dev->kobj, | ||
2039 | it87_attributes_fan_div[i]); | ||
2040 | if (err) | ||
2041 | goto error; | ||
2042 | } | ||
2043 | |||
2099 | if (sio_data->beep_pin) { | 2044 | if (sio_data->beep_pin) { |
2100 | err = sysfs_create_file(&dev->kobj, | 2045 | err = sysfs_create_file(&dev->kobj, |
2101 | it87_attributes_fan_beep[i]); | 2046 | it87_attributes_fan_beep[i]); |
@@ -2414,15 +2359,15 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
2414 | if (!(data->has_fan & (1 << i))) | 2359 | if (!(data->has_fan & (1 << i))) |
2415 | continue; | 2360 | continue; |
2416 | 2361 | ||
2417 | data->fan_min[i] = | 2362 | data->fan[i][1] = |
2418 | it87_read_value(data, IT87_REG_FAN_MIN[i]); | 2363 | it87_read_value(data, IT87_REG_FAN_MIN[i]); |
2419 | data->fan[i] = it87_read_value(data, | 2364 | data->fan[i][0] = it87_read_value(data, |
2420 | IT87_REG_FAN[i]); | 2365 | IT87_REG_FAN[i]); |
2421 | /* Add high byte if in 16-bit mode */ | 2366 | /* Add high byte if in 16-bit mode */ |
2422 | if (has_16bit_fans(data)) { | 2367 | if (has_16bit_fans(data)) { |
2423 | data->fan[i] |= it87_read_value(data, | 2368 | data->fan[i][0] |= it87_read_value(data, |
2424 | IT87_REG_FANX[i]) << 8; | 2369 | IT87_REG_FANX[i]) << 8; |
2425 | data->fan_min[i] |= it87_read_value(data, | 2370 | data->fan[i][1] |= it87_read_value(data, |
2426 | IT87_REG_FANX_MIN[i]) << 8; | 2371 | IT87_REG_FANX_MIN[i]) << 8; |
2427 | } | 2372 | } |
2428 | } | 2373 | } |