diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-24 15:16:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:18 -0400 |
commit | 0e39e01c908fdc498fff0d788fd7b955ab75ebb6 (patch) | |
tree | 2e117466ec9a60f3dac6d678e95af97454aa6c8c /drivers/hwmon/f71805f.c | |
parent | 681c6f7a6702f208d48b501c8829dbc03a2ca238 (diff) |
hwmon: Fix unchecked return status, batch 4
hwmon: Fix unchecked return status, batch 4
Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Note: f71805f actually checked the status from device_create_file
already. However it did not remove the files on device destruction.
It was also an opportunity to use sysfs_create/remove_group instead
of hand-made loops. This makes the changes much more important but
I think the result is worth it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r-- | drivers/hwmon/f71805f.c | 324 |
1 files changed, 203 insertions, 121 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index 678bae43716d..de17a72149d9 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/hwmon-sysfs.h> | 31 | #include <linux/hwmon-sysfs.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
34 | #include <linux/sysfs.h> | ||
34 | #include <asm/io.h> | 35 | #include <asm/io.h> |
35 | 36 | ||
36 | static struct platform_device *pdev; | 37 | static struct platform_device *pdev; |
@@ -593,104 +594,189 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
593 | return sprintf(buf, "%s\n", data->name); | 594 | return sprintf(buf, "%s\n", data->name); |
594 | } | 595 | } |
595 | 596 | ||
596 | static struct device_attribute f71805f_dev_attr[] = { | 597 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); |
597 | __ATTR(in0_input, S_IRUGO, show_in0, NULL), | 598 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); |
598 | __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), | 599 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); |
599 | __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), | 600 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); |
600 | __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), | 601 | static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, |
601 | __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), | 602 | show_in_max, set_in_max, 1); |
602 | __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), | 603 | static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO | S_IWUSR, |
603 | __ATTR(name, S_IRUGO, show_name, NULL), | 604 | show_in_min, set_in_min, 1); |
605 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2); | ||
606 | static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
607 | show_in_max, set_in_max, 2); | ||
608 | static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
609 | show_in_min, set_in_min, 2); | ||
610 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3); | ||
611 | static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
612 | show_in_max, set_in_max, 3); | ||
613 | static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
614 | show_in_min, set_in_min, 3); | ||
615 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4); | ||
616 | static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
617 | show_in_max, set_in_max, 4); | ||
618 | static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
619 | show_in_min, set_in_min, 4); | ||
620 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in, NULL, 5); | ||
621 | static SENSOR_DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
622 | show_in_max, set_in_max, 5); | ||
623 | static SENSOR_DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
624 | show_in_min, set_in_min, 5); | ||
625 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in, NULL, 6); | ||
626 | static SENSOR_DEVICE_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
627 | show_in_max, set_in_max, 6); | ||
628 | static SENSOR_DEVICE_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
629 | show_in_min, set_in_min, 6); | ||
630 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in, NULL, 7); | ||
631 | static SENSOR_DEVICE_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
632 | show_in_max, set_in_max, 7); | ||
633 | static SENSOR_DEVICE_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
634 | show_in_min, set_in_min, 7); | ||
635 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_in, NULL, 8); | ||
636 | static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
637 | show_in_max, set_in_max, 8); | ||
638 | static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
639 | show_in_min, set_in_min, 8); | ||
640 | |||
641 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | ||
642 | static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, | ||
643 | show_fan_min, set_fan_min, 0); | ||
644 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | ||
645 | static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR, | ||
646 | show_fan_min, set_fan_min, 1); | ||
647 | static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); | ||
648 | static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR, | ||
649 | show_fan_min, set_fan_min, 2); | ||
650 | |||
651 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | ||
652 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
653 | show_temp_max, set_temp_max, 0); | ||
654 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
655 | show_temp_hyst, set_temp_hyst, 0); | ||
656 | static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0); | ||
657 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | ||
658 | static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
659 | show_temp_max, set_temp_max, 1); | ||
660 | static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
661 | show_temp_hyst, set_temp_hyst, 1); | ||
662 | static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1); | ||
663 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); | ||
664 | static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
665 | show_temp_max, set_temp_max, 2); | ||
666 | static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
667 | show_temp_hyst, set_temp_hyst, 2); | ||
668 | static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); | ||
669 | |||
670 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
671 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
672 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
673 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
674 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
675 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5); | ||
676 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
677 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); | ||
678 | static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
679 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
680 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12); | ||
681 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); | ||
682 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16); | ||
683 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17); | ||
684 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18); | ||
685 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); | ||
686 | static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); | ||
687 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | ||
688 | |||
689 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | ||
690 | |||
691 | static struct attribute *f71805f_attributes[] = { | ||
692 | &dev_attr_in0_input.attr, | ||
693 | &dev_attr_in0_max.attr, | ||
694 | &dev_attr_in0_min.attr, | ||
695 | &sensor_dev_attr_in1_input.dev_attr.attr, | ||
696 | &sensor_dev_attr_in1_max.dev_attr.attr, | ||
697 | &sensor_dev_attr_in1_min.dev_attr.attr, | ||
698 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
699 | &sensor_dev_attr_in2_max.dev_attr.attr, | ||
700 | &sensor_dev_attr_in2_min.dev_attr.attr, | ||
701 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
702 | &sensor_dev_attr_in3_max.dev_attr.attr, | ||
703 | &sensor_dev_attr_in3_min.dev_attr.attr, | ||
704 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
705 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
706 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
707 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
708 | &sensor_dev_attr_in5_max.dev_attr.attr, | ||
709 | &sensor_dev_attr_in5_min.dev_attr.attr, | ||
710 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
711 | &sensor_dev_attr_in6_max.dev_attr.attr, | ||
712 | &sensor_dev_attr_in6_min.dev_attr.attr, | ||
713 | &sensor_dev_attr_in7_input.dev_attr.attr, | ||
714 | &sensor_dev_attr_in7_max.dev_attr.attr, | ||
715 | &sensor_dev_attr_in7_min.dev_attr.attr, | ||
716 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
717 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
718 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
719 | |||
720 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
721 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
722 | &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, | ||
723 | &sensor_dev_attr_temp1_type.dev_attr.attr, | ||
724 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
725 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
726 | &sensor_dev_attr_temp2_max_hyst.dev_attr.attr, | ||
727 | &sensor_dev_attr_temp2_type.dev_attr.attr, | ||
728 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
729 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
730 | &sensor_dev_attr_temp3_max_hyst.dev_attr.attr, | ||
731 | &sensor_dev_attr_temp3_type.dev_attr.attr, | ||
732 | |||
733 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
734 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
735 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
736 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
737 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
738 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
739 | &sensor_dev_attr_in6_alarm.dev_attr.attr, | ||
740 | &sensor_dev_attr_in7_alarm.dev_attr.attr, | ||
741 | &sensor_dev_attr_in8_alarm.dev_attr.attr, | ||
742 | &dev_attr_alarms_in.attr, | ||
743 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
744 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
745 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
746 | &dev_attr_alarms_temp.attr, | ||
747 | &dev_attr_alarms_fan.attr, | ||
748 | |||
749 | &dev_attr_name.attr, | ||
750 | NULL | ||
604 | }; | 751 | }; |
605 | 752 | ||
606 | static struct sensor_device_attribute f71805f_sensor_attr[] = { | 753 | static const struct attribute_group f71805f_group = { |
607 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | 754 | .attrs = f71805f_attributes, |
608 | SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, | ||
609 | show_in_max, set_in_max, 1), | ||
610 | SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, | ||
611 | show_in_min, set_in_min, 1), | ||
612 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
613 | SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
614 | show_in_max, set_in_max, 2), | ||
615 | SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
616 | show_in_min, set_in_min, 2), | ||
617 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
618 | SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
619 | show_in_max, set_in_max, 3), | ||
620 | SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
621 | show_in_min, set_in_min, 3), | ||
622 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
623 | SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
624 | show_in_max, set_in_max, 4), | ||
625 | SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
626 | show_in_min, set_in_min, 4), | ||
627 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
628 | SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
629 | show_in_max, set_in_max, 5), | ||
630 | SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
631 | show_in_min, set_in_min, 5), | ||
632 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
633 | SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
634 | show_in_max, set_in_max, 6), | ||
635 | SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
636 | show_in_min, set_in_min, 6), | ||
637 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
638 | SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
639 | show_in_max, set_in_max, 7), | ||
640 | SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
641 | show_in_min, set_in_min, 7), | ||
642 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
643 | SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
644 | show_in_max, set_in_max, 8), | ||
645 | SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
646 | show_in_min, set_in_min, 8), | ||
647 | |||
648 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), | ||
649 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
650 | show_temp_max, set_temp_max, 0), | ||
651 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
652 | show_temp_hyst, set_temp_hyst, 0), | ||
653 | SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), | ||
654 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), | ||
655 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
656 | show_temp_max, set_temp_max, 1), | ||
657 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
658 | show_temp_hyst, set_temp_hyst, 1), | ||
659 | SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), | ||
660 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), | ||
661 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
662 | show_temp_max, set_temp_max, 2), | ||
663 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
664 | show_temp_hyst, set_temp_hyst, 2), | ||
665 | SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), | ||
666 | |||
667 | SENSOR_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0), | ||
668 | SENSOR_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1), | ||
669 | SENSOR_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2), | ||
670 | SENSOR_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3), | ||
671 | SENSOR_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4), | ||
672 | SENSOR_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5), | ||
673 | SENSOR_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6), | ||
674 | SENSOR_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7), | ||
675 | SENSOR_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8), | ||
676 | SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11), | ||
677 | SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12), | ||
678 | SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13), | ||
679 | }; | 755 | }; |
680 | 756 | ||
681 | static struct sensor_device_attribute f71805f_fan_attr[] = { | 757 | static struct attribute *f71805f_attributes_fan[3][4] = { |
682 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), | 758 | { |
683 | SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, | 759 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
684 | show_fan_min, set_fan_min, 0), | 760 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
685 | SENSOR_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16), | 761 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
686 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), | 762 | NULL |
687 | SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, | 763 | }, { |
688 | show_fan_min, set_fan_min, 1), | 764 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
689 | SENSOR_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17), | 765 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
690 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), | 766 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
691 | SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, | 767 | NULL |
692 | show_fan_min, set_fan_min, 2), | 768 | }, { |
693 | SENSOR_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18), | 769 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
770 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
771 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
772 | NULL | ||
773 | } | ||
774 | }; | ||
775 | |||
776 | static const struct attribute_group f71805f_group_fan[3] = { | ||
777 | { .attrs = f71805f_attributes_fan[0] }, | ||
778 | { .attrs = f71805f_attributes_fan[1] }, | ||
779 | { .attrs = f71805f_attributes_fan[2] }, | ||
694 | }; | 780 | }; |
695 | 781 | ||
696 | /* | 782 | /* |
@@ -738,43 +824,35 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
738 | 824 | ||
739 | platform_set_drvdata(pdev, data); | 825 | platform_set_drvdata(pdev, data); |
740 | 826 | ||
741 | data->class_dev = hwmon_device_register(&pdev->dev); | ||
742 | if (IS_ERR(data->class_dev)) { | ||
743 | err = PTR_ERR(data->class_dev); | ||
744 | dev_err(&pdev->dev, "Class registration failed (%d)\n", err); | ||
745 | goto exit_free; | ||
746 | } | ||
747 | |||
748 | /* Initialize the F71805F chip */ | 827 | /* Initialize the F71805F chip */ |
749 | f71805f_init_device(data); | 828 | f71805f_init_device(data); |
750 | 829 | ||
751 | /* Register sysfs interface files */ | 830 | /* Register sysfs interface files */ |
752 | for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { | 831 | if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) |
753 | err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); | 832 | goto exit_free; |
754 | if (err) | 833 | for (i = 0; i < 3; i++) { |
755 | goto exit_class; | 834 | if (!(data->fan_enabled & (1 << i))) |
756 | } | ||
757 | for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { | ||
758 | err = device_create_file(&pdev->dev, | ||
759 | &f71805f_sensor_attr[i].dev_attr); | ||
760 | if (err) | ||
761 | goto exit_class; | ||
762 | } | ||
763 | for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { | ||
764 | if (!(data->fan_enabled & (1 << (i / 3)))) | ||
765 | continue; | 835 | continue; |
766 | err = device_create_file(&pdev->dev, | 836 | if ((err = sysfs_create_group(&pdev->dev.kobj, |
767 | &f71805f_fan_attr[i].dev_attr); | 837 | &f71805f_group_fan[i]))) |
768 | if (err) | 838 | goto exit_remove_files; |
769 | goto exit_class; | 839 | } |
840 | |||
841 | data->class_dev = hwmon_device_register(&pdev->dev); | ||
842 | if (IS_ERR(data->class_dev)) { | ||
843 | err = PTR_ERR(data->class_dev); | ||
844 | dev_err(&pdev->dev, "Class registration failed (%d)\n", err); | ||
845 | goto exit_remove_files; | ||
770 | } | 846 | } |
771 | 847 | ||
772 | return 0; | 848 | return 0; |
773 | 849 | ||
774 | exit_class: | 850 | exit_remove_files: |
775 | dev_err(&pdev->dev, "Sysfs interface creation failed\n"); | 851 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); |
776 | hwmon_device_unregister(data->class_dev); | 852 | for (i = 0; i < 3; i++) |
853 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); | ||
777 | exit_free: | 854 | exit_free: |
855 | platform_set_drvdata(pdev, NULL); | ||
778 | kfree(data); | 856 | kfree(data); |
779 | exit: | 857 | exit: |
780 | return err; | 858 | return err; |
@@ -783,9 +861,13 @@ exit: | |||
783 | static int __devexit f71805f_remove(struct platform_device *pdev) | 861 | static int __devexit f71805f_remove(struct platform_device *pdev) |
784 | { | 862 | { |
785 | struct f71805f_data *data = platform_get_drvdata(pdev); | 863 | struct f71805f_data *data = platform_get_drvdata(pdev); |
864 | int i; | ||
786 | 865 | ||
787 | platform_set_drvdata(pdev, NULL); | 866 | platform_set_drvdata(pdev, NULL); |
788 | hwmon_device_unregister(data->class_dev); | 867 | hwmon_device_unregister(data->class_dev); |
868 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group); | ||
869 | for (i = 0; i < 3; i++) | ||
870 | sysfs_remove_group(&pdev->dev.kobj, &f71805f_group_fan[i]); | ||
789 | kfree(data); | 871 | kfree(data); |
790 | 872 | ||
791 | return 0; | 873 | return 0; |