diff options
author | Rudolf Marek <r.marek@assembler.cz> | 2006-09-24 15:24:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:18 -0400 |
commit | f52f79da2908796a0fa1e7bbbe0d5ff20183d75f (patch) | |
tree | 32de8a34992593136d42381d9503a9f4bc85506f /drivers/hwmon/w83792d.c | |
parent | ccc5c306957bb7fbaef61de249bac4b0f09f2336 (diff) |
w83792d: Fix unchecked return status
w83792d: Fix unchecked return status
Fix the w83792d driver. Add error checking to device_create_file
and also care to destroy the files upon exit.
Signed-off-by: Rudolf Marek <r.marek@assembler.cz>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/w83792d.c')
-rw-r--r-- | drivers/hwmon/w83792d.c | 554 |
1 files changed, 323 insertions, 231 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 7576ec9426a3..4e108262576f 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/hwmon-sysfs.h> | 43 | #include <linux/hwmon-sysfs.h> |
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <linux/mutex.h> | 45 | #include <linux/mutex.h> |
46 | #include <linux/sysfs.h> | ||
46 | 47 | ||
47 | /* Addresses to scan */ | 48 | /* Addresses to scan */ |
48 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; | 49 | static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; |
@@ -381,41 +382,6 @@ static ssize_t store_in_##reg (struct device *dev, \ | |||
381 | store_in_reg(MIN, min); | 382 | store_in_reg(MIN, min); |
382 | store_in_reg(MAX, max); | 383 | store_in_reg(MAX, max); |
383 | 384 | ||
384 | static struct sensor_device_attribute sda_in_input[] = { | ||
385 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), | ||
386 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
387 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
388 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
389 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
390 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
391 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
392 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
393 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
394 | }; | ||
395 | static struct sensor_device_attribute sda_in_min[] = { | ||
396 | SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0), | ||
397 | SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1), | ||
398 | SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2), | ||
399 | SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3), | ||
400 | SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4), | ||
401 | SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5), | ||
402 | SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6), | ||
403 | SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7), | ||
404 | SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8), | ||
405 | }; | ||
406 | static struct sensor_device_attribute sda_in_max[] = { | ||
407 | SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0), | ||
408 | SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1), | ||
409 | SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2), | ||
410 | SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3), | ||
411 | SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4), | ||
412 | SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5), | ||
413 | SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6), | ||
414 | SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7), | ||
415 | SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8), | ||
416 | }; | ||
417 | |||
418 | |||
419 | #define show_fan_reg(reg) \ | 385 | #define show_fan_reg(reg) \ |
420 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ | 386 | static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \ |
421 | char *buf) \ | 387 | char *buf) \ |
@@ -499,35 +465,6 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
499 | return count; | 465 | return count; |
500 | } | 466 | } |
501 | 467 | ||
502 | static struct sensor_device_attribute sda_fan_input[] = { | ||
503 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1), | ||
504 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2), | ||
505 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3), | ||
506 | SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4), | ||
507 | SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5), | ||
508 | SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6), | ||
509 | SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7), | ||
510 | }; | ||
511 | static struct sensor_device_attribute sda_fan_min[] = { | ||
512 | SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1), | ||
513 | SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2), | ||
514 | SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3), | ||
515 | SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4), | ||
516 | SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5), | ||
517 | SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6), | ||
518 | SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7), | ||
519 | }; | ||
520 | static struct sensor_device_attribute sda_fan_div[] = { | ||
521 | SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1), | ||
522 | SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2), | ||
523 | SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3), | ||
524 | SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4), | ||
525 | SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5), | ||
526 | SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6), | ||
527 | SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7), | ||
528 | }; | ||
529 | |||
530 | |||
531 | /* read/write the temperature1, includes measured value and limits */ | 468 | /* read/write the temperature1, includes measured value and limits */ |
532 | 469 | ||
533 | static ssize_t show_temp1(struct device *dev, struct device_attribute *attr, | 470 | static ssize_t show_temp1(struct device *dev, struct device_attribute *attr, |
@@ -595,24 +532,6 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | |||
595 | return count; | 532 | return count; |
596 | } | 533 | } |
597 | 534 | ||
598 | static struct sensor_device_attribute_2 sda_temp_input[] = { | ||
599 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0), | ||
600 | SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0), | ||
601 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0), | ||
602 | }; | ||
603 | |||
604 | static struct sensor_device_attribute_2 sda_temp_max[] = { | ||
605 | SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1), | ||
606 | SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2), | ||
607 | SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2), | ||
608 | }; | ||
609 | |||
610 | static struct sensor_device_attribute_2 sda_temp_max_hyst[] = { | ||
611 | SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2), | ||
612 | SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4), | ||
613 | SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4), | ||
614 | }; | ||
615 | |||
616 | /* get reatime status of all sensors items: voltage, temp, fan */ | 535 | /* get reatime status of all sensors items: voltage, temp, fan */ |
617 | static ssize_t | 536 | static ssize_t |
618 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 537 | show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -621,9 +540,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | |||
621 | return sprintf(buf, "%d\n", data->alarms); | 540 | return sprintf(buf, "%d\n", data->alarms); |
622 | } | 541 | } |
623 | 542 | ||
624 | static | ||
625 | DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | ||
626 | |||
627 | static ssize_t | 543 | static ssize_t |
628 | show_pwm(struct device *dev, struct device_attribute *attr, | 544 | show_pwm(struct device *dev, struct device_attribute *attr, |
629 | char *buf) | 545 | char *buf) |
@@ -715,21 +631,6 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
715 | return count; | 631 | return count; |
716 | } | 632 | } |
717 | 633 | ||
718 | static struct sensor_device_attribute sda_pwm[] = { | ||
719 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0), | ||
720 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), | ||
721 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), | ||
722 | }; | ||
723 | static struct sensor_device_attribute sda_pwm_enable[] = { | ||
724 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, | ||
725 | show_pwmenable, store_pwmenable, 1), | ||
726 | SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, | ||
727 | show_pwmenable, store_pwmenable, 2), | ||
728 | SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, | ||
729 | show_pwmenable, store_pwmenable, 3), | ||
730 | }; | ||
731 | |||
732 | |||
733 | static ssize_t | 634 | static ssize_t |
734 | show_pwm_mode(struct device *dev, struct device_attribute *attr, | 635 | show_pwm_mode(struct device *dev, struct device_attribute *attr, |
735 | char *buf) | 636 | char *buf) |
@@ -767,16 +668,6 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
767 | return count; | 668 | return count; |
768 | } | 669 | } |
769 | 670 | ||
770 | static struct sensor_device_attribute sda_pwm_mode[] = { | ||
771 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, | ||
772 | show_pwm_mode, store_pwm_mode, 0), | ||
773 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | ||
774 | show_pwm_mode, store_pwm_mode, 1), | ||
775 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, | ||
776 | show_pwm_mode, store_pwm_mode, 2), | ||
777 | }; | ||
778 | |||
779 | |||
780 | static ssize_t | 671 | static ssize_t |
781 | show_regs_chassis(struct device *dev, struct device_attribute *attr, | 672 | show_regs_chassis(struct device *dev, struct device_attribute *attr, |
782 | char *buf) | 673 | char *buf) |
@@ -785,8 +676,6 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr, | |||
785 | return sprintf(buf, "%d\n", data->chassis); | 676 | return sprintf(buf, "%d\n", data->chassis); |
786 | } | 677 | } |
787 | 678 | ||
788 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); | ||
789 | |||
790 | static ssize_t | 679 | static ssize_t |
791 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) | 680 | show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) |
792 | { | 681 | { |
@@ -815,9 +704,6 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr, | |||
815 | return count; | 704 | return count; |
816 | } | 705 | } |
817 | 706 | ||
818 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, | ||
819 | show_chassis_clear, store_chassis_clear); | ||
820 | |||
821 | /* For Smart Fan I / Thermal Cruise */ | 707 | /* For Smart Fan I / Thermal Cruise */ |
822 | static ssize_t | 708 | static ssize_t |
823 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, | 709 | show_thermal_cruise(struct device *dev, struct device_attribute *attr, |
@@ -853,15 +739,6 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
853 | return count; | 739 | return count; |
854 | } | 740 | } |
855 | 741 | ||
856 | static struct sensor_device_attribute sda_thermal_cruise[] = { | ||
857 | SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, | ||
858 | show_thermal_cruise, store_thermal_cruise, 1), | ||
859 | SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, | ||
860 | show_thermal_cruise, store_thermal_cruise, 2), | ||
861 | SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, | ||
862 | show_thermal_cruise, store_thermal_cruise, 3), | ||
863 | }; | ||
864 | |||
865 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ | 742 | /* For Smart Fan I/Thermal Cruise and Smart Fan II */ |
866 | static ssize_t | 743 | static ssize_t |
867 | show_tolerance(struct device *dev, struct device_attribute *attr, | 744 | show_tolerance(struct device *dev, struct device_attribute *attr, |
@@ -901,15 +778,6 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
901 | return count; | 778 | return count; |
902 | } | 779 | } |
903 | 780 | ||
904 | static struct sensor_device_attribute sda_tolerance[] = { | ||
905 | SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO, | ||
906 | show_tolerance, store_tolerance, 1), | ||
907 | SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO, | ||
908 | show_tolerance, store_tolerance, 2), | ||
909 | SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO, | ||
910 | show_tolerance, store_tolerance, 3), | ||
911 | }; | ||
912 | |||
913 | /* For Smart Fan II */ | 781 | /* For Smart Fan II */ |
914 | static ssize_t | 782 | static ssize_t |
915 | show_sf2_point(struct device *dev, struct device_attribute *attr, | 783 | show_sf2_point(struct device *dev, struct device_attribute *attr, |
@@ -946,36 +814,6 @@ store_sf2_point(struct device *dev, struct device_attribute *attr, | |||
946 | return count; | 814 | return count; |
947 | } | 815 | } |
948 | 816 | ||
949 | static struct sensor_device_attribute_2 sda_sf2_point[] = { | ||
950 | SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, | ||
951 | show_sf2_point, store_sf2_point, 1, 1), | ||
952 | SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, | ||
953 | show_sf2_point, store_sf2_point, 2, 1), | ||
954 | SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, | ||
955 | show_sf2_point, store_sf2_point, 3, 1), | ||
956 | SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, | ||
957 | show_sf2_point, store_sf2_point, 4, 1), | ||
958 | |||
959 | SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, | ||
960 | show_sf2_point, store_sf2_point, 1, 2), | ||
961 | SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, | ||
962 | show_sf2_point, store_sf2_point, 2, 2), | ||
963 | SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, | ||
964 | show_sf2_point, store_sf2_point, 3, 2), | ||
965 | SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, | ||
966 | show_sf2_point, store_sf2_point, 4, 2), | ||
967 | |||
968 | SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, | ||
969 | show_sf2_point, store_sf2_point, 1, 3), | ||
970 | SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, | ||
971 | show_sf2_point, store_sf2_point, 2, 3), | ||
972 | SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, | ||
973 | show_sf2_point, store_sf2_point, 3, 3), | ||
974 | SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, | ||
975 | show_sf2_point, store_sf2_point, 4, 3), | ||
976 | }; | ||
977 | |||
978 | |||
979 | static ssize_t | 817 | static ssize_t |
980 | show_sf2_level(struct device *dev, struct device_attribute *attr, | 818 | show_sf2_level(struct device *dev, struct device_attribute *attr, |
981 | char *buf) | 819 | char *buf) |
@@ -1016,29 +854,6 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
1016 | return count; | 854 | return count; |
1017 | } | 855 | } |
1018 | 856 | ||
1019 | static struct sensor_device_attribute_2 sda_sf2_level[] = { | ||
1020 | SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, | ||
1021 | show_sf2_level, store_sf2_level, 1, 1), | ||
1022 | SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, | ||
1023 | show_sf2_level, store_sf2_level, 2, 1), | ||
1024 | SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, | ||
1025 | show_sf2_level, store_sf2_level, 3, 1), | ||
1026 | |||
1027 | SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, | ||
1028 | show_sf2_level, store_sf2_level, 1, 2), | ||
1029 | SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, | ||
1030 | show_sf2_level, store_sf2_level, 2, 2), | ||
1031 | SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, | ||
1032 | show_sf2_level, store_sf2_level, 3, 2), | ||
1033 | |||
1034 | SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, | ||
1035 | show_sf2_level, store_sf2_level, 1, 3), | ||
1036 | SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, | ||
1037 | show_sf2_level, store_sf2_level, 2, 3), | ||
1038 | SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, | ||
1039 | show_sf2_level, store_sf2_level, 3, 3), | ||
1040 | }; | ||
1041 | |||
1042 | /* This function is called when: | 857 | /* This function is called when: |
1043 | * w83792d_driver is inserted (when this module is loaded), for each | 858 | * w83792d_driver is inserted (when this module is loaded), for each |
1044 | available adapter | 859 | available adapter |
@@ -1139,12 +954,297 @@ ERROR_SC_0: | |||
1139 | return err; | 954 | return err; |
1140 | } | 955 | } |
1141 | 956 | ||
1142 | static void device_create_file_fan(struct device *dev, int i) | 957 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0); |
1143 | { | 958 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); |
1144 | device_create_file(dev, &sda_fan_input[i].dev_attr); | 959 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2); |
1145 | device_create_file(dev, &sda_fan_div[i].dev_attr); | 960 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3); |
1146 | device_create_file(dev, &sda_fan_min[i].dev_attr); | 961 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4); |
1147 | } | 962 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in, NULL, 5); |
963 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in, NULL, 6); | ||
964 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in, NULL, 7); | ||
965 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_in, NULL, 8); | ||
966 | static SENSOR_DEVICE_ATTR(in0_min, S_IWUSR | S_IRUGO, | ||
967 | show_in_min, store_in_min, 0); | ||
968 | static SENSOR_DEVICE_ATTR(in1_min, S_IWUSR | S_IRUGO, | ||
969 | show_in_min, store_in_min, 1); | ||
970 | static SENSOR_DEVICE_ATTR(in2_min, S_IWUSR | S_IRUGO, | ||
971 | show_in_min, store_in_min, 2); | ||
972 | static SENSOR_DEVICE_ATTR(in3_min, S_IWUSR | S_IRUGO, | ||
973 | show_in_min, store_in_min, 3); | ||
974 | static SENSOR_DEVICE_ATTR(in4_min, S_IWUSR | S_IRUGO, | ||
975 | show_in_min, store_in_min, 4); | ||
976 | static SENSOR_DEVICE_ATTR(in5_min, S_IWUSR | S_IRUGO, | ||
977 | show_in_min, store_in_min, 5); | ||
978 | static SENSOR_DEVICE_ATTR(in6_min, S_IWUSR | S_IRUGO, | ||
979 | show_in_min, store_in_min, 6); | ||
980 | static SENSOR_DEVICE_ATTR(in7_min, S_IWUSR | S_IRUGO, | ||
981 | show_in_min, store_in_min, 7); | ||
982 | static SENSOR_DEVICE_ATTR(in8_min, S_IWUSR | S_IRUGO, | ||
983 | show_in_min, store_in_min, 8); | ||
984 | static SENSOR_DEVICE_ATTR(in0_max, S_IWUSR | S_IRUGO, | ||
985 | show_in_max, store_in_max, 0); | ||
986 | static SENSOR_DEVICE_ATTR(in1_max, S_IWUSR | S_IRUGO, | ||
987 | show_in_max, store_in_max, 1); | ||
988 | static SENSOR_DEVICE_ATTR(in2_max, S_IWUSR | S_IRUGO, | ||
989 | show_in_max, store_in_max, 2); | ||
990 | static SENSOR_DEVICE_ATTR(in3_max, S_IWUSR | S_IRUGO, | ||
991 | show_in_max, store_in_max, 3); | ||
992 | static SENSOR_DEVICE_ATTR(in4_max, S_IWUSR | S_IRUGO, | ||
993 | show_in_max, store_in_max, 4); | ||
994 | static SENSOR_DEVICE_ATTR(in5_max, S_IWUSR | S_IRUGO, | ||
995 | show_in_max, store_in_max, 5); | ||
996 | static SENSOR_DEVICE_ATTR(in6_max, S_IWUSR | S_IRUGO, | ||
997 | show_in_max, store_in_max, 6); | ||
998 | static SENSOR_DEVICE_ATTR(in7_max, S_IWUSR | S_IRUGO, | ||
999 | show_in_max, store_in_max, 7); | ||
1000 | static SENSOR_DEVICE_ATTR(in8_max, S_IWUSR | S_IRUGO, | ||
1001 | show_in_max, store_in_max, 8); | ||
1002 | static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0); | ||
1003 | static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0); | ||
1004 | static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0); | ||
1005 | static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, | ||
1006 | show_temp1, store_temp1, 0, 1); | ||
1007 | static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, | ||
1008 | store_temp23, 0, 2); | ||
1009 | static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, | ||
1010 | store_temp23, 1, 2); | ||
1011 | static SENSOR_DEVICE_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
1012 | show_temp1, store_temp1, 0, 2); | ||
1013 | static SENSOR_DEVICE_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
1014 | show_temp23, store_temp23, 0, 4); | ||
1015 | static SENSOR_DEVICE_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
1016 | show_temp23, store_temp23, 1, 4); | ||
1017 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | ||
1018 | static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); | ||
1019 | static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, | ||
1020 | show_chassis_clear, store_chassis_clear); | ||
1021 | static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0); | ||
1022 | static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1); | ||
1023 | static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2); | ||
1024 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, | ||
1025 | show_pwmenable, store_pwmenable, 1); | ||
1026 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, | ||
1027 | show_pwmenable, store_pwmenable, 2); | ||
1028 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, | ||
1029 | show_pwmenable, store_pwmenable, 3); | ||
1030 | static SENSOR_DEVICE_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, | ||
1031 | show_pwm_mode, store_pwm_mode, 0); | ||
1032 | static SENSOR_DEVICE_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | ||
1033 | show_pwm_mode, store_pwm_mode, 1); | ||
1034 | static SENSOR_DEVICE_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, | ||
1035 | show_pwm_mode, store_pwm_mode, 2); | ||
1036 | static SENSOR_DEVICE_ATTR(tolerance1, S_IWUSR | S_IRUGO, | ||
1037 | show_tolerance, store_tolerance, 1); | ||
1038 | static SENSOR_DEVICE_ATTR(tolerance2, S_IWUSR | S_IRUGO, | ||
1039 | show_tolerance, store_tolerance, 2); | ||
1040 | static SENSOR_DEVICE_ATTR(tolerance3, S_IWUSR | S_IRUGO, | ||
1041 | show_tolerance, store_tolerance, 3); | ||
1042 | static SENSOR_DEVICE_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO, | ||
1043 | show_thermal_cruise, store_thermal_cruise, 1); | ||
1044 | static SENSOR_DEVICE_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO, | ||
1045 | show_thermal_cruise, store_thermal_cruise, 2); | ||
1046 | static SENSOR_DEVICE_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO, | ||
1047 | show_thermal_cruise, store_thermal_cruise, 3); | ||
1048 | static SENSOR_DEVICE_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR, | ||
1049 | show_sf2_point, store_sf2_point, 1, 1); | ||
1050 | static SENSOR_DEVICE_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR, | ||
1051 | show_sf2_point, store_sf2_point, 2, 1); | ||
1052 | static SENSOR_DEVICE_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR, | ||
1053 | show_sf2_point, store_sf2_point, 3, 1); | ||
1054 | static SENSOR_DEVICE_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR, | ||
1055 | show_sf2_point, store_sf2_point, 4, 1); | ||
1056 | static SENSOR_DEVICE_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR, | ||
1057 | show_sf2_point, store_sf2_point, 1, 2); | ||
1058 | static SENSOR_DEVICE_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR, | ||
1059 | show_sf2_point, store_sf2_point, 2, 2); | ||
1060 | static SENSOR_DEVICE_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR, | ||
1061 | show_sf2_point, store_sf2_point, 3, 2); | ||
1062 | static SENSOR_DEVICE_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR, | ||
1063 | show_sf2_point, store_sf2_point, 4, 2); | ||
1064 | static SENSOR_DEVICE_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR, | ||
1065 | show_sf2_point, store_sf2_point, 1, 3); | ||
1066 | static SENSOR_DEVICE_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR, | ||
1067 | show_sf2_point, store_sf2_point, 2, 3); | ||
1068 | static SENSOR_DEVICE_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR, | ||
1069 | show_sf2_point, store_sf2_point, 3, 3); | ||
1070 | static SENSOR_DEVICE_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR, | ||
1071 | show_sf2_point, store_sf2_point, 4, 3); | ||
1072 | static SENSOR_DEVICE_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR, | ||
1073 | show_sf2_level, store_sf2_level, 1, 1); | ||
1074 | static SENSOR_DEVICE_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR, | ||
1075 | show_sf2_level, store_sf2_level, 2, 1); | ||
1076 | static SENSOR_DEVICE_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR, | ||
1077 | show_sf2_level, store_sf2_level, 3, 1); | ||
1078 | static SENSOR_DEVICE_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR, | ||
1079 | show_sf2_level, store_sf2_level, 1, 2); | ||
1080 | static SENSOR_DEVICE_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR, | ||
1081 | show_sf2_level, store_sf2_level, 2, 2); | ||
1082 | static SENSOR_DEVICE_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR, | ||
1083 | show_sf2_level, store_sf2_level, 3, 2); | ||
1084 | static SENSOR_DEVICE_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR, | ||
1085 | show_sf2_level, store_sf2_level, 1, 3); | ||
1086 | static SENSOR_DEVICE_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR, | ||
1087 | show_sf2_level, store_sf2_level, 2, 3); | ||
1088 | static SENSOR_DEVICE_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR, | ||
1089 | show_sf2_level, store_sf2_level, 3, 3); | ||
1090 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1); | ||
1091 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2); | ||
1092 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3); | ||
1093 | static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4); | ||
1094 | static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5); | ||
1095 | static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6); | ||
1096 | static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7); | ||
1097 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, | ||
1098 | show_fan_min, store_fan_min, 1); | ||
1099 | static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, | ||
1100 | show_fan_min, store_fan_min, 2); | ||
1101 | static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, | ||
1102 | show_fan_min, store_fan_min, 3); | ||
1103 | static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, | ||
1104 | show_fan_min, store_fan_min, 4); | ||
1105 | static SENSOR_DEVICE_ATTR(fan5_min, S_IWUSR | S_IRUGO, | ||
1106 | show_fan_min, store_fan_min, 5); | ||
1107 | static SENSOR_DEVICE_ATTR(fan6_min, S_IWUSR | S_IRUGO, | ||
1108 | show_fan_min, store_fan_min, 6); | ||
1109 | static SENSOR_DEVICE_ATTR(fan7_min, S_IWUSR | S_IRUGO, | ||
1110 | show_fan_min, store_fan_min, 7); | ||
1111 | static SENSOR_DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO, | ||
1112 | show_fan_div, store_fan_div, 1); | ||
1113 | static SENSOR_DEVICE_ATTR(fan2_div, S_IWUSR | S_IRUGO, | ||
1114 | show_fan_div, store_fan_div, 2); | ||
1115 | static SENSOR_DEVICE_ATTR(fan3_div, S_IWUSR | S_IRUGO, | ||
1116 | show_fan_div, store_fan_div, 3); | ||
1117 | static SENSOR_DEVICE_ATTR(fan4_div, S_IWUSR | S_IRUGO, | ||
1118 | show_fan_div, store_fan_div, 4); | ||
1119 | static SENSOR_DEVICE_ATTR(fan5_div, S_IWUSR | S_IRUGO, | ||
1120 | show_fan_div, store_fan_div, 5); | ||
1121 | static SENSOR_DEVICE_ATTR(fan6_div, S_IWUSR | S_IRUGO, | ||
1122 | show_fan_div, store_fan_div, 6); | ||
1123 | static SENSOR_DEVICE_ATTR(fan7_div, S_IWUSR | S_IRUGO, | ||
1124 | show_fan_div, store_fan_div, 7); | ||
1125 | |||
1126 | static struct attribute *w83792d_attributes_fan[4][4] = { | ||
1127 | { | ||
1128 | &sensor_dev_attr_fan4_input.dev_attr.attr, | ||
1129 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
1130 | &sensor_dev_attr_fan4_div.dev_attr.attr, | ||
1131 | NULL | ||
1132 | }, { | ||
1133 | &sensor_dev_attr_fan5_input.dev_attr.attr, | ||
1134 | &sensor_dev_attr_fan5_min.dev_attr.attr, | ||
1135 | &sensor_dev_attr_fan5_div.dev_attr.attr, | ||
1136 | NULL | ||
1137 | }, { | ||
1138 | &sensor_dev_attr_fan6_input.dev_attr.attr, | ||
1139 | &sensor_dev_attr_fan6_min.dev_attr.attr, | ||
1140 | &sensor_dev_attr_fan6_div.dev_attr.attr, | ||
1141 | NULL | ||
1142 | }, { | ||
1143 | &sensor_dev_attr_fan7_input.dev_attr.attr, | ||
1144 | &sensor_dev_attr_fan7_min.dev_attr.attr, | ||
1145 | &sensor_dev_attr_fan7_div.dev_attr.attr, | ||
1146 | NULL | ||
1147 | } | ||
1148 | }; | ||
1149 | |||
1150 | static const struct attribute_group w83792d_group_fan[4] = { | ||
1151 | { .attrs = w83792d_attributes_fan[0] }, | ||
1152 | { .attrs = w83792d_attributes_fan[1] }, | ||
1153 | { .attrs = w83792d_attributes_fan[2] }, | ||
1154 | { .attrs = w83792d_attributes_fan[3] }, | ||
1155 | }; | ||
1156 | |||
1157 | static struct attribute *w83792d_attributes[] = { | ||
1158 | &sensor_dev_attr_in0_input.dev_attr.attr, | ||
1159 | &sensor_dev_attr_in0_max.dev_attr.attr, | ||
1160 | &sensor_dev_attr_in0_min.dev_attr.attr, | ||
1161 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
1162 | &sensor_dev_attr_in1_max.dev_attr.attr, | ||
1163 | &sensor_dev_attr_in1_min.dev_attr.attr, | ||
1164 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
1165 | &sensor_dev_attr_in2_max.dev_attr.attr, | ||
1166 | &sensor_dev_attr_in2_min.dev_attr.attr, | ||
1167 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
1168 | &sensor_dev_attr_in3_max.dev_attr.attr, | ||
1169 | &sensor_dev_attr_in3_min.dev_attr.attr, | ||
1170 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
1171 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
1172 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
1173 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
1174 | &sensor_dev_attr_in5_max.dev_attr.attr, | ||
1175 | &sensor_dev_attr_in5_min.dev_attr.attr, | ||
1176 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
1177 | &sensor_dev_attr_in6_max.dev_attr.attr, | ||
1178 | &sensor_dev_attr_in6_min.dev_attr.attr, | ||
1179 | &sensor_dev_attr_in7_input.dev_attr.attr, | ||
1180 | &sensor_dev_attr_in7_max.dev_attr.attr, | ||
1181 | &sensor_dev_attr_in7_min.dev_attr.attr, | ||
1182 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
1183 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
1184 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
1185 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
1186 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
1187 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, | ||
1188 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
1189 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
1190 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, | ||
1191 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
1192 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
1193 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, | ||
1194 | &sensor_dev_attr_pwm1.dev_attr.attr, | ||
1195 | &sensor_dev_attr_pwm1_mode.dev_attr.attr, | ||
1196 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1197 | &sensor_dev_attr_pwm2.dev_attr.attr, | ||
1198 | &sensor_dev_attr_pwm2_mode.dev_attr.attr, | ||
1199 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1200 | &sensor_dev_attr_pwm3.dev_attr.attr, | ||
1201 | &sensor_dev_attr_pwm3_mode.dev_attr.attr, | ||
1202 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1203 | &dev_attr_alarms.attr, | ||
1204 | &dev_attr_chassis.attr, | ||
1205 | &dev_attr_chassis_clear.attr, | ||
1206 | &sensor_dev_attr_tolerance1.dev_attr.attr, | ||
1207 | &sensor_dev_attr_thermal_cruise1.dev_attr.attr, | ||
1208 | &sensor_dev_attr_tolerance2.dev_attr.attr, | ||
1209 | &sensor_dev_attr_thermal_cruise2.dev_attr.attr, | ||
1210 | &sensor_dev_attr_tolerance3.dev_attr.attr, | ||
1211 | &sensor_dev_attr_thermal_cruise3.dev_attr.attr, | ||
1212 | &sensor_dev_attr_sf2_point1_fan1.dev_attr.attr, | ||
1213 | &sensor_dev_attr_sf2_point2_fan1.dev_attr.attr, | ||
1214 | &sensor_dev_attr_sf2_point3_fan1.dev_attr.attr, | ||
1215 | &sensor_dev_attr_sf2_point4_fan1.dev_attr.attr, | ||
1216 | &sensor_dev_attr_sf2_point1_fan2.dev_attr.attr, | ||
1217 | &sensor_dev_attr_sf2_point2_fan2.dev_attr.attr, | ||
1218 | &sensor_dev_attr_sf2_point3_fan2.dev_attr.attr, | ||
1219 | &sensor_dev_attr_sf2_point4_fan2.dev_attr.attr, | ||
1220 | &sensor_dev_attr_sf2_point1_fan3.dev_attr.attr, | ||
1221 | &sensor_dev_attr_sf2_point2_fan3.dev_attr.attr, | ||
1222 | &sensor_dev_attr_sf2_point3_fan3.dev_attr.attr, | ||
1223 | &sensor_dev_attr_sf2_point4_fan3.dev_attr.attr, | ||
1224 | &sensor_dev_attr_sf2_level1_fan1.dev_attr.attr, | ||
1225 | &sensor_dev_attr_sf2_level2_fan1.dev_attr.attr, | ||
1226 | &sensor_dev_attr_sf2_level3_fan1.dev_attr.attr, | ||
1227 | &sensor_dev_attr_sf2_level1_fan2.dev_attr.attr, | ||
1228 | &sensor_dev_attr_sf2_level2_fan2.dev_attr.attr, | ||
1229 | &sensor_dev_attr_sf2_level3_fan2.dev_attr.attr, | ||
1230 | &sensor_dev_attr_sf2_level1_fan3.dev_attr.attr, | ||
1231 | &sensor_dev_attr_sf2_level2_fan3.dev_attr.attr, | ||
1232 | &sensor_dev_attr_sf2_level3_fan3.dev_attr.attr, | ||
1233 | &sensor_dev_attr_fan1_input.dev_attr.attr, | ||
1234 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1235 | &sensor_dev_attr_fan1_div.dev_attr.attr, | ||
1236 | &sensor_dev_attr_fan2_input.dev_attr.attr, | ||
1237 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
1238 | &sensor_dev_attr_fan2_div.dev_attr.attr, | ||
1239 | &sensor_dev_attr_fan3_input.dev_attr.attr, | ||
1240 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
1241 | &sensor_dev_attr_fan3_div.dev_attr.attr, | ||
1242 | NULL | ||
1243 | }; | ||
1244 | |||
1245 | static const struct attribute_group w83792d_group = { | ||
1246 | .attrs = w83792d_attributes, | ||
1247 | }; | ||
1148 | 1248 | ||
1149 | static int | 1249 | static int |
1150 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | 1250 | w83792d_detect(struct i2c_adapter *adapter, int address, int kind) |
@@ -1268,59 +1368,46 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
1268 | } | 1368 | } |
1269 | 1369 | ||
1270 | /* Register sysfs hooks */ | 1370 | /* Register sysfs hooks */ |
1271 | data->class_dev = hwmon_device_register(dev); | 1371 | if ((err = sysfs_create_group(&dev->kobj, &w83792d_group))) |
1272 | if (IS_ERR(data->class_dev)) { | ||
1273 | err = PTR_ERR(data->class_dev); | ||
1274 | goto ERROR3; | 1372 | goto ERROR3; |
1275 | } | ||
1276 | for (i = 0; i < 9; i++) { | ||
1277 | device_create_file(dev, &sda_in_input[i].dev_attr); | ||
1278 | device_create_file(dev, &sda_in_max[i].dev_attr); | ||
1279 | device_create_file(dev, &sda_in_min[i].dev_attr); | ||
1280 | } | ||
1281 | for (i = 0; i < 3; i++) | ||
1282 | device_create_file_fan(dev, i); | ||
1283 | 1373 | ||
1284 | /* Read GPIO enable register to check if pins for fan 4,5 are used as | 1374 | /* Read GPIO enable register to check if pins for fan 4,5 are used as |
1285 | GPIO */ | 1375 | GPIO */ |
1286 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); | 1376 | val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN); |
1377 | |||
1287 | if (!(val1 & 0x40)) | 1378 | if (!(val1 & 0x40)) |
1288 | device_create_file_fan(dev, 3); | 1379 | if ((err = sysfs_create_group(&dev->kobj, |
1380 | &w83792d_group_fan[0]))) | ||
1381 | goto exit_remove_files; | ||
1382 | |||
1289 | if (!(val1 & 0x20)) | 1383 | if (!(val1 & 0x20)) |
1290 | device_create_file_fan(dev, 4); | 1384 | if ((err = sysfs_create_group(&dev->kobj, |
1385 | &w83792d_group_fan[1]))) | ||
1386 | goto exit_remove_files; | ||
1291 | 1387 | ||
1292 | val1 = w83792d_read_value(client, W83792D_REG_PIN); | 1388 | val1 = w83792d_read_value(client, W83792D_REG_PIN); |
1293 | if (val1 & 0x40) | 1389 | if (val1 & 0x40) |
1294 | device_create_file_fan(dev, 5); | 1390 | if ((err = sysfs_create_group(&dev->kobj, |
1391 | &w83792d_group_fan[2]))) | ||
1392 | goto exit_remove_files; | ||
1393 | |||
1295 | if (val1 & 0x04) | 1394 | if (val1 & 0x04) |
1296 | device_create_file_fan(dev, 6); | 1395 | if ((err = sysfs_create_group(&dev->kobj, |
1297 | 1396 | &w83792d_group_fan[3]))) | |
1298 | for (i = 0; i < 3; i++) { | 1397 | goto exit_remove_files; |
1299 | device_create_file(dev, &sda_temp_input[i].dev_attr); | ||
1300 | device_create_file(dev, &sda_temp_max[i].dev_attr); | ||
1301 | device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); | ||
1302 | device_create_file(dev, &sda_thermal_cruise[i].dev_attr); | ||
1303 | device_create_file(dev, &sda_tolerance[i].dev_attr); | ||
1304 | } | ||
1305 | 1398 | ||
1306 | for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) { | 1399 | data->class_dev = hwmon_device_register(dev); |
1307 | device_create_file(dev, &sda_pwm[i].dev_attr); | 1400 | if (IS_ERR(data->class_dev)) { |
1308 | device_create_file(dev, &sda_pwm_enable[i].dev_attr); | 1401 | err = PTR_ERR(data->class_dev); |
1309 | device_create_file(dev, &sda_pwm_mode[i].dev_attr); | 1402 | goto exit_remove_files; |
1310 | } | 1403 | } |
1311 | 1404 | ||
1312 | device_create_file(dev, &dev_attr_alarms); | ||
1313 | device_create_file(dev, &dev_attr_chassis); | ||
1314 | device_create_file(dev, &dev_attr_chassis_clear); | ||
1315 | |||
1316 | for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++) | ||
1317 | device_create_file(dev, &sda_sf2_point[i].dev_attr); | ||
1318 | |||
1319 | for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++) | ||
1320 | device_create_file(dev, &sda_sf2_level[i].dev_attr); | ||
1321 | |||
1322 | return 0; | 1405 | return 0; |
1323 | 1406 | ||
1407 | exit_remove_files: | ||
1408 | sysfs_remove_group(&dev->kobj, &w83792d_group); | ||
1409 | for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++) | ||
1410 | sysfs_remove_group(&dev->kobj, &w83792d_group_fan[i]); | ||
1324 | ERROR3: | 1411 | ERROR3: |
1325 | if (data->lm75[0] != NULL) { | 1412 | if (data->lm75[0] != NULL) { |
1326 | i2c_detach_client(data->lm75[0]); | 1413 | i2c_detach_client(data->lm75[0]); |
@@ -1342,11 +1429,16 @@ static int | |||
1342 | w83792d_detach_client(struct i2c_client *client) | 1429 | w83792d_detach_client(struct i2c_client *client) |
1343 | { | 1430 | { |
1344 | struct w83792d_data *data = i2c_get_clientdata(client); | 1431 | struct w83792d_data *data = i2c_get_clientdata(client); |
1345 | int err; | 1432 | int err, i; |
1346 | 1433 | ||
1347 | /* main client */ | 1434 | /* main client */ |
1348 | if (data) | 1435 | if (data) { |
1349 | hwmon_device_unregister(data->class_dev); | 1436 | hwmon_device_unregister(data->class_dev); |
1437 | sysfs_remove_group(&client->dev.kobj, &w83792d_group); | ||
1438 | for (i = 0; i < ARRAY_SIZE(w83792d_group_fan); i++) | ||
1439 | sysfs_remove_group(&client->dev.kobj, | ||
1440 | &w83792d_group_fan[i]); | ||
1441 | } | ||
1350 | 1442 | ||
1351 | if ((err = i2c_detach_client(client))) | 1443 | if ((err = i2c_detach_client(client))) |
1352 | return err; | 1444 | return err; |