aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-09-24 15:16:40 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-28 18:31:18 -0400
commit0e39e01c908fdc498fff0d788fd7b955ab75ebb6 (patch)
tree2e117466ec9a60f3dac6d678e95af97454aa6c8c
parent681c6f7a6702f208d48b501c8829dbc03a2ca238 (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>
-rw-r--r--drivers/hwmon/f71805f.c324
-rw-r--r--drivers/hwmon/lm63.c89
-rw-r--r--drivers/hwmon/lm83.c125
-rw-r--r--drivers/hwmon/lm90.c83
4 files changed, 357 insertions, 264 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
36static struct platform_device *pdev; 37static 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
596static struct device_attribute f71805f_dev_attr[] = { 597static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL);
597 __ATTR(in0_input, S_IRUGO, show_in0, NULL), 598static 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), 599static 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), 600static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1);
600 __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), 601static 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), 603static 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);
605static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2);
606static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO | S_IWUSR,
607 show_in_max, set_in_max, 2);
608static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO | S_IWUSR,
609 show_in_min, set_in_min, 2);
610static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3);
611static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO | S_IWUSR,
612 show_in_max, set_in_max, 3);
613static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO | S_IWUSR,
614 show_in_min, set_in_min, 3);
615static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4);
616static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO | S_IWUSR,
617 show_in_max, set_in_max, 4);
618static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO | S_IWUSR,
619 show_in_min, set_in_min, 4);
620static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in, NULL, 5);
621static SENSOR_DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR,
622 show_in_max, set_in_max, 5);
623static SENSOR_DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR,
624 show_in_min, set_in_min, 5);
625static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, show_in, NULL, 6);
626static SENSOR_DEVICE_ATTR(in6_max, S_IRUGO | S_IWUSR,
627 show_in_max, set_in_max, 6);
628static SENSOR_DEVICE_ATTR(in6_min, S_IRUGO | S_IWUSR,
629 show_in_min, set_in_min, 6);
630static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in, NULL, 7);
631static SENSOR_DEVICE_ATTR(in7_max, S_IRUGO | S_IWUSR,
632 show_in_max, set_in_max, 7);
633static SENSOR_DEVICE_ATTR(in7_min, S_IRUGO | S_IWUSR,
634 show_in_min, set_in_min, 7);
635static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, show_in, NULL, 8);
636static SENSOR_DEVICE_ATTR(in8_max, S_IRUGO | S_IWUSR,
637 show_in_max, set_in_max, 8);
638static SENSOR_DEVICE_ATTR(in8_min, S_IRUGO | S_IWUSR,
639 show_in_min, set_in_min, 8);
640
641static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
642static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR,
643 show_fan_min, set_fan_min, 0);
644static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
645static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO | S_IWUSR,
646 show_fan_min, set_fan_min, 1);
647static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
648static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO | S_IWUSR,
649 show_fan_min, set_fan_min, 2);
650
651static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
652static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
653 show_temp_max, set_temp_max, 0);
654static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
655 show_temp_hyst, set_temp_hyst, 0);
656static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0);
657static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
658static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR,
659 show_temp_max, set_temp_max, 1);
660static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR,
661 show_temp_hyst, set_temp_hyst, 1);
662static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1);
663static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
664static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR,
665 show_temp_max, set_temp_max, 2);
666static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,
667 show_temp_hyst, set_temp_hyst, 2);
668static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2);
669
670static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
671static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
672static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
673static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
674static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4);
675static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5);
676static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6);
677static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7);
678static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 8);
679static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 11);
680static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 12);
681static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
682static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16);
683static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17);
684static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18);
685static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);
686static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);
687static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
688
689static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
690
691static 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
606static struct sensor_device_attribute f71805f_sensor_attr[] = { 753static 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
681static struct sensor_device_attribute f71805f_fan_attr[] = { 757static 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
776static 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
774exit_class: 850exit_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]);
777exit_free: 854exit_free:
855 platform_set_drvdata(pdev, NULL);
778 kfree(data); 856 kfree(data);
779exit: 857exit:
780 return err; 858 return err;
@@ -783,9 +861,13 @@ exit:
783static int __devexit f71805f_remove(struct platform_device *pdev) 861static 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;
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 00a50bea7cbd..d69f3cf07122 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -46,6 +46,7 @@
46#include <linux/hwmon.h> 46#include <linux/hwmon.h>
47#include <linux/err.h> 47#include <linux/err.h>
48#include <linux/mutex.h> 48#include <linux/mutex.h>
49#include <linux/sysfs.h>
49 50
50/* 51/*
51 * Addresses to scan 52 * Addresses to scan
@@ -370,6 +371,42 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
370/* Raw alarm file for compatibility */ 371/* Raw alarm file for compatibility */
371static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 372static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
372 373
374static struct attribute *lm63_attributes[] = {
375 &dev_attr_pwm1.attr,
376 &dev_attr_pwm1_enable.attr,
377 &sensor_dev_attr_temp1_input.dev_attr.attr,
378 &sensor_dev_attr_temp2_input.dev_attr.attr,
379 &sensor_dev_attr_temp2_min.dev_attr.attr,
380 &sensor_dev_attr_temp1_max.dev_attr.attr,
381 &sensor_dev_attr_temp2_max.dev_attr.attr,
382 &sensor_dev_attr_temp2_crit.dev_attr.attr,
383 &dev_attr_temp2_crit_hyst.attr,
384
385 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
386 &sensor_dev_attr_temp2_input_fault.dev_attr.attr,
387 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
388 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
389 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
390 &dev_attr_alarms.attr,
391 NULL
392};
393
394static const struct attribute_group lm63_group = {
395 .attrs = lm63_attributes,
396};
397
398static struct attribute *lm63_attributes_fan1[] = {
399 &sensor_dev_attr_fan1_input.dev_attr.attr,
400 &sensor_dev_attr_fan1_min.dev_attr.attr,
401
402 &sensor_dev_attr_fan1_min_alarm.dev_attr.attr,
403 NULL
404};
405
406static const struct attribute_group lm63_group_fan1 = {
407 .attrs = lm63_attributes_fan1,
408};
409
373/* 410/*
374 * Real code 411 * Real code
375 */ 412 */
@@ -456,50 +493,26 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
456 lm63_init_client(new_client); 493 lm63_init_client(new_client);
457 494
458 /* Register sysfs hooks */ 495 /* Register sysfs hooks */
459 data->class_dev = hwmon_device_register(&new_client->dev); 496 if ((err = sysfs_create_group(&new_client->dev.kobj,
460 if (IS_ERR(data->class_dev)) { 497 &lm63_group)))
461 err = PTR_ERR(data->class_dev);
462 goto exit_detach; 498 goto exit_detach;
499 if (data->config & 0x04) { /* tachometer enabled */
500 if ((err = sysfs_create_group(&new_client->dev.kobj,
501 &lm63_group_fan1)))
502 goto exit_remove_files;
463 } 503 }
464 504
465 if (data->config & 0x04) { /* tachometer enabled */ 505 data->class_dev = hwmon_device_register(&new_client->dev);
466 device_create_file(&new_client->dev, 506 if (IS_ERR(data->class_dev)) {
467 &sensor_dev_attr_fan1_input.dev_attr); 507 err = PTR_ERR(data->class_dev);
468 device_create_file(&new_client->dev, 508 goto exit_remove_files;
469 &sensor_dev_attr_fan1_min.dev_attr);
470 device_create_file(&new_client->dev,
471 &sensor_dev_attr_fan1_min_alarm.dev_attr);
472 } 509 }
473 device_create_file(&new_client->dev, &dev_attr_pwm1);
474 device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
475 device_create_file(&new_client->dev,
476 &sensor_dev_attr_temp1_input.dev_attr);
477 device_create_file(&new_client->dev,
478 &sensor_dev_attr_temp2_input.dev_attr);
479 device_create_file(&new_client->dev,
480 &sensor_dev_attr_temp2_min.dev_attr);
481 device_create_file(&new_client->dev,
482 &sensor_dev_attr_temp1_max.dev_attr);
483 device_create_file(&new_client->dev,
484 &sensor_dev_attr_temp2_max.dev_attr);
485 device_create_file(&new_client->dev,
486 &sensor_dev_attr_temp2_crit.dev_attr);
487 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);
488
489 device_create_file(&new_client->dev,
490 &sensor_dev_attr_temp2_input_fault.dev_attr);
491 device_create_file(&new_client->dev,
492 &sensor_dev_attr_temp2_min_alarm.dev_attr);
493 device_create_file(&new_client->dev,
494 &sensor_dev_attr_temp1_max_alarm.dev_attr);
495 device_create_file(&new_client->dev,
496 &sensor_dev_attr_temp2_max_alarm.dev_attr);
497 device_create_file(&new_client->dev,
498 &sensor_dev_attr_temp2_crit_alarm.dev_attr);
499 device_create_file(&new_client->dev, &dev_attr_alarms);
500 510
501 return 0; 511 return 0;
502 512
513exit_remove_files:
514 sysfs_remove_group(&new_client->dev.kobj, &lm63_group);
515 sysfs_remove_group(&new_client->dev.kobj, &lm63_group_fan1);
503exit_detach: 516exit_detach:
504 i2c_detach_client(new_client); 517 i2c_detach_client(new_client);
505exit_free: 518exit_free:
@@ -549,6 +562,8 @@ static int lm63_detach_client(struct i2c_client *client)
549 int err; 562 int err;
550 563
551 hwmon_device_unregister(data->class_dev); 564 hwmon_device_unregister(data->class_dev);
565 sysfs_remove_group(&client->dev.kobj, &lm63_group);
566 sysfs_remove_group(&client->dev.kobj, &lm63_group_fan1);
552 567
553 if ((err = i2c_detach_client(client))) 568 if ((err = i2c_detach_client(client)))
554 return err; 569 return err;
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index ea224891d311..feb87b41e986 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -40,6 +40,7 @@
40#include <linux/hwmon.h> 40#include <linux/hwmon.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43#include <linux/sysfs.h>
43 44
44/* 45/*
45 * Addresses to scan 46 * Addresses to scan
@@ -234,6 +235,48 @@ static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 15);
234/* Raw alarm file for compatibility */ 235/* Raw alarm file for compatibility */
235static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 236static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
236 237
238static struct attribute *lm83_attributes[] = {
239 &sensor_dev_attr_temp1_input.dev_attr.attr,
240 &sensor_dev_attr_temp3_input.dev_attr.attr,
241 &sensor_dev_attr_temp1_max.dev_attr.attr,
242 &sensor_dev_attr_temp3_max.dev_attr.attr,
243 &sensor_dev_attr_temp1_crit.dev_attr.attr,
244 &sensor_dev_attr_temp3_crit.dev_attr.attr,
245
246 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
247 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
248 &sensor_dev_attr_temp3_input_fault.dev_attr.attr,
249 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
250 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
251 &dev_attr_alarms.attr,
252 NULL
253};
254
255static const struct attribute_group lm83_group = {
256 .attrs = lm83_attributes,
257};
258
259static struct attribute *lm83_attributes_opt[] = {
260 &sensor_dev_attr_temp2_input.dev_attr.attr,
261 &sensor_dev_attr_temp4_input.dev_attr.attr,
262 &sensor_dev_attr_temp2_max.dev_attr.attr,
263 &sensor_dev_attr_temp4_max.dev_attr.attr,
264 &sensor_dev_attr_temp2_crit.dev_attr.attr,
265 &sensor_dev_attr_temp4_crit.dev_attr.attr,
266
267 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
268 &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr,
269 &sensor_dev_attr_temp4_input_fault.dev_attr.attr,
270 &sensor_dev_attr_temp4_max_alarm.dev_attr.attr,
271 &sensor_dev_attr_temp2_input_fault.dev_attr.attr,
272 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
273 NULL
274};
275
276static const struct attribute_group lm83_group_opt = {
277 .attrs = lm83_attributes_opt,
278};
279
237/* 280/*
238 * Real code 281 * Real code
239 */ 282 */
@@ -342,82 +385,32 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
342 goto exit_free; 385 goto exit_free;
343 386
344 /* 387 /*
345 * Initialize the LM83 chip 388 * Register sysfs hooks
346 * (Nothing to do for this one.)
347 */
348
349 /* Register sysfs hooks */
350 data->class_dev = hwmon_device_register(&new_client->dev);
351 if (IS_ERR(data->class_dev)) {
352 err = PTR_ERR(data->class_dev);
353 goto exit_detach;
354 }
355
356 /*
357 * The LM82 can only monitor one external diode which is 389 * The LM82 can only monitor one external diode which is
358 * at the same register as the LM83 temp3 entry - so we 390 * at the same register as the LM83 temp3 entry - so we
359 * declare 1 and 3 common, and then 2 and 4 only for the LM83. 391 * declare 1 and 3 common, and then 2 and 4 only for the LM83.
360 */ 392 */
361 393
362 device_create_file(&new_client->dev, 394 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm83_group)))
363 &sensor_dev_attr_temp1_input.dev_attr); 395 goto exit_detach;
364 device_create_file(&new_client->dev,
365 &sensor_dev_attr_temp3_input.dev_attr);
366
367 device_create_file(&new_client->dev,
368 &sensor_dev_attr_temp1_max.dev_attr);
369 device_create_file(&new_client->dev,
370 &sensor_dev_attr_temp3_max.dev_attr);
371
372 device_create_file(&new_client->dev,
373 &sensor_dev_attr_temp1_crit.dev_attr);
374 device_create_file(&new_client->dev,
375 &sensor_dev_attr_temp3_crit.dev_attr);
376
377 device_create_file(&new_client->dev,
378 &sensor_dev_attr_temp3_input_fault.dev_attr);
379 device_create_file(&new_client->dev,
380 &sensor_dev_attr_temp1_max_alarm.dev_attr);
381 device_create_file(&new_client->dev,
382 &sensor_dev_attr_temp3_max_alarm.dev_attr);
383 device_create_file(&new_client->dev,
384 &sensor_dev_attr_temp1_crit_alarm.dev_attr);
385 device_create_file(&new_client->dev,
386 &sensor_dev_attr_temp3_crit_alarm.dev_attr);
387 device_create_file(&new_client->dev, &dev_attr_alarms);
388 396
389 if (kind == lm83) { 397 if (kind == lm83) {
390 device_create_file(&new_client->dev, 398 if ((err = sysfs_create_group(&new_client->dev.kobj,
391 &sensor_dev_attr_temp2_input.dev_attr); 399 &lm83_group_opt)))
392 device_create_file(&new_client->dev, 400 goto exit_remove_files;
393 &sensor_dev_attr_temp4_input.dev_attr); 401 }
394 402
395 device_create_file(&new_client->dev, 403 data->class_dev = hwmon_device_register(&new_client->dev);
396 &sensor_dev_attr_temp2_max.dev_attr); 404 if (IS_ERR(data->class_dev)) {
397 device_create_file(&new_client->dev, 405 err = PTR_ERR(data->class_dev);
398 &sensor_dev_attr_temp4_max.dev_attr); 406 goto exit_remove_files;
399
400 device_create_file(&new_client->dev,
401 &sensor_dev_attr_temp2_crit.dev_attr);
402 device_create_file(&new_client->dev,
403 &sensor_dev_attr_temp4_crit.dev_attr);
404
405 device_create_file(&new_client->dev,
406 &sensor_dev_attr_temp2_input_fault.dev_attr);
407 device_create_file(&new_client->dev,
408 &sensor_dev_attr_temp4_input_fault.dev_attr);
409 device_create_file(&new_client->dev,
410 &sensor_dev_attr_temp2_max_alarm.dev_attr);
411 device_create_file(&new_client->dev,
412 &sensor_dev_attr_temp4_max_alarm.dev_attr);
413 device_create_file(&new_client->dev,
414 &sensor_dev_attr_temp2_crit_alarm.dev_attr);
415 device_create_file(&new_client->dev,
416 &sensor_dev_attr_temp4_crit_alarm.dev_attr);
417 } 407 }
418 408
419 return 0; 409 return 0;
420 410
411exit_remove_files:
412 sysfs_remove_group(&new_client->dev.kobj, &lm83_group);
413 sysfs_remove_group(&new_client->dev.kobj, &lm83_group_opt);
421exit_detach: 414exit_detach:
422 i2c_detach_client(new_client); 415 i2c_detach_client(new_client);
423exit_free: 416exit_free:
@@ -432,6 +425,8 @@ static int lm83_detach_client(struct i2c_client *client)
432 int err; 425 int err;
433 426
434 hwmon_device_unregister(data->class_dev); 427 hwmon_device_unregister(data->class_dev);
428 sysfs_remove_group(&client->dev.kobj, &lm83_group);
429 sysfs_remove_group(&client->dev.kobj, &lm83_group_opt);
435 430
436 if ((err = i2c_detach_client(client))) 431 if ((err = i2c_detach_client(client)))
437 return err; 432 return err;
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 77f8e3f7fd49..6882ce75feee 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -79,6 +79,7 @@
79#include <linux/hwmon.h> 79#include <linux/hwmon.h>
80#include <linux/err.h> 80#include <linux/err.h>
81#include <linux/mutex.h> 81#include <linux/mutex.h>
82#include <linux/sysfs.h>
82 83
83/* 84/*
84 * Addresses to scan 85 * Addresses to scan
@@ -366,6 +367,33 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
366/* Raw alarm file for compatibility */ 367/* Raw alarm file for compatibility */
367static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 368static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
368 369
370static struct attribute *lm90_attributes[] = {
371 &sensor_dev_attr_temp1_input.dev_attr.attr,
372 &sensor_dev_attr_temp2_input.dev_attr.attr,
373 &sensor_dev_attr_temp1_min.dev_attr.attr,
374 &sensor_dev_attr_temp2_min.dev_attr.attr,
375 &sensor_dev_attr_temp1_max.dev_attr.attr,
376 &sensor_dev_attr_temp2_max.dev_attr.attr,
377 &sensor_dev_attr_temp1_crit.dev_attr.attr,
378 &sensor_dev_attr_temp2_crit.dev_attr.attr,
379 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
380 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
381
382 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
383 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
384 &sensor_dev_attr_temp2_input_fault.dev_attr.attr,
385 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
386 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
387 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
388 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
389 &dev_attr_alarms.attr,
390 NULL
391};
392
393static const struct attribute_group lm90_group = {
394 .attrs = lm90_attributes,
395};
396
369/* pec used for ADM1032 only */ 397/* pec used for ADM1032 only */
370static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, 398static ssize_t show_pec(struct device *dev, struct device_attribute *dummy,
371 char *buf) 399 char *buf)
@@ -589,54 +617,25 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
589 lm90_init_client(new_client); 617 lm90_init_client(new_client);
590 618
591 /* Register sysfs hooks */ 619 /* Register sysfs hooks */
620 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm90_group)))
621 goto exit_detach;
622 if (new_client->flags & I2C_CLIENT_PEC) {
623 if ((err = device_create_file(&new_client->dev,
624 &dev_attr_pec)))
625 goto exit_remove_files;
626 }
627
592 data->class_dev = hwmon_device_register(&new_client->dev); 628 data->class_dev = hwmon_device_register(&new_client->dev);
593 if (IS_ERR(data->class_dev)) { 629 if (IS_ERR(data->class_dev)) {
594 err = PTR_ERR(data->class_dev); 630 err = PTR_ERR(data->class_dev);
595 goto exit_detach; 631 goto exit_remove_files;
596 } 632 }
597 633
598 device_create_file(&new_client->dev,
599 &sensor_dev_attr_temp1_input.dev_attr);
600 device_create_file(&new_client->dev,
601 &sensor_dev_attr_temp2_input.dev_attr);
602 device_create_file(&new_client->dev,
603 &sensor_dev_attr_temp1_min.dev_attr);
604 device_create_file(&new_client->dev,
605 &sensor_dev_attr_temp2_min.dev_attr);
606 device_create_file(&new_client->dev,
607 &sensor_dev_attr_temp1_max.dev_attr);
608 device_create_file(&new_client->dev,
609 &sensor_dev_attr_temp2_max.dev_attr);
610 device_create_file(&new_client->dev,
611 &sensor_dev_attr_temp1_crit.dev_attr);
612 device_create_file(&new_client->dev,
613 &sensor_dev_attr_temp2_crit.dev_attr);
614 device_create_file(&new_client->dev,
615 &sensor_dev_attr_temp1_crit_hyst.dev_attr);
616 device_create_file(&new_client->dev,
617 &sensor_dev_attr_temp2_crit_hyst.dev_attr);
618
619 device_create_file(&new_client->dev,
620 &sensor_dev_attr_temp2_input_fault.dev_attr);
621 device_create_file(&new_client->dev,
622 &sensor_dev_attr_temp1_min_alarm.dev_attr);
623 device_create_file(&new_client->dev,
624 &sensor_dev_attr_temp2_min_alarm.dev_attr);
625 device_create_file(&new_client->dev,
626 &sensor_dev_attr_temp1_max_alarm.dev_attr);
627 device_create_file(&new_client->dev,
628 &sensor_dev_attr_temp2_max_alarm.dev_attr);
629 device_create_file(&new_client->dev,
630 &sensor_dev_attr_temp1_crit_alarm.dev_attr);
631 device_create_file(&new_client->dev,
632 &sensor_dev_attr_temp2_crit_alarm.dev_attr);
633 device_create_file(&new_client->dev, &dev_attr_alarms);
634
635 if (new_client->flags & I2C_CLIENT_PEC)
636 device_create_file(&new_client->dev, &dev_attr_pec);
637
638 return 0; 634 return 0;
639 635
636exit_remove_files:
637 sysfs_remove_group(&new_client->dev.kobj, &lm90_group);
638 device_remove_file(&new_client->dev, &dev_attr_pec);
640exit_detach: 639exit_detach:
641 i2c_detach_client(new_client); 640 i2c_detach_client(new_client);
642exit_free: 641exit_free:
@@ -669,6 +668,8 @@ static int lm90_detach_client(struct i2c_client *client)
669 int err; 668 int err;
670 669
671 hwmon_device_unregister(data->class_dev); 670 hwmon_device_unregister(data->class_dev);
671 sysfs_remove_group(&client->dev.kobj, &lm90_group);
672 device_remove_file(&client->dev, &dev_attr_pec);
672 673
673 if ((err = i2c_detach_client(client))) 674 if ((err = i2c_detach_client(client)))
674 return err; 675 return err;