diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2006-10-08 15:56:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-10-18 16:03:08 -0400 |
commit | 34fc921a253f3ddfc4ad9de1dbc88683f84fbaaa (patch) | |
tree | 9e1bc568db0226d8dfaa6535fce80437696ea134 | |
parent | 73ed9a86cd77b6a3b46beec8d353ac3b0d4f50c1 (diff) |
w83791d: Fix unchecked return status
Replace all unchecked calls to device_create_file with a single group
declaration, and one call to sysfs_create_group, and check that one
return status. Also remove the files on device detach.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off by: Charles Spirakis <bezaur@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/hwmon/w83791d.c | 85 |
1 files changed, 56 insertions, 29 deletions
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index 371ed4f69a97..9e5f885368b4 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
@@ -746,6 +746,52 @@ static ssize_t store_vrm_reg(struct device *dev, | |||
746 | 746 | ||
747 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | 747 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); |
748 | 748 | ||
749 | #define IN_UNIT_ATTRS(X) \ | ||
750 | &sda_in_input[X].dev_attr.attr, \ | ||
751 | &sda_in_min[X].dev_attr.attr, \ | ||
752 | &sda_in_max[X].dev_attr.attr | ||
753 | |||
754 | #define FAN_UNIT_ATTRS(X) \ | ||
755 | &sda_fan_input[X].dev_attr.attr, \ | ||
756 | &sda_fan_min[X].dev_attr.attr, \ | ||
757 | &sda_fan_div[X].dev_attr.attr | ||
758 | |||
759 | #define TEMP_UNIT_ATTRS(X) \ | ||
760 | &sda_temp_input[X].dev_attr.attr, \ | ||
761 | &sda_temp_max[X].dev_attr.attr, \ | ||
762 | &sda_temp_max_hyst[X].dev_attr.attr | ||
763 | |||
764 | static struct attribute *w83791d_attributes[] = { | ||
765 | IN_UNIT_ATTRS(0), | ||
766 | IN_UNIT_ATTRS(1), | ||
767 | IN_UNIT_ATTRS(2), | ||
768 | IN_UNIT_ATTRS(3), | ||
769 | IN_UNIT_ATTRS(4), | ||
770 | IN_UNIT_ATTRS(5), | ||
771 | IN_UNIT_ATTRS(6), | ||
772 | IN_UNIT_ATTRS(7), | ||
773 | IN_UNIT_ATTRS(8), | ||
774 | IN_UNIT_ATTRS(9), | ||
775 | FAN_UNIT_ATTRS(0), | ||
776 | FAN_UNIT_ATTRS(1), | ||
777 | FAN_UNIT_ATTRS(2), | ||
778 | FAN_UNIT_ATTRS(3), | ||
779 | FAN_UNIT_ATTRS(4), | ||
780 | TEMP_UNIT_ATTRS(0), | ||
781 | TEMP_UNIT_ATTRS(1), | ||
782 | TEMP_UNIT_ATTRS(2), | ||
783 | &dev_attr_alarms.attr, | ||
784 | &sda_beep_ctrl[0].dev_attr.attr, | ||
785 | &sda_beep_ctrl[1].dev_attr.attr, | ||
786 | &dev_attr_cpu0_vid.attr, | ||
787 | &dev_attr_vrm.attr, | ||
788 | NULL | ||
789 | }; | ||
790 | |||
791 | static const struct attribute_group w83791d_group = { | ||
792 | .attrs = w83791d_attributes, | ||
793 | }; | ||
794 | |||
749 | /* This function is called when: | 795 | /* This function is called when: |
750 | * w83791d_driver is inserted (when this module is loaded), for each | 796 | * w83791d_driver is inserted (when this module is loaded), for each |
751 | available adapter | 797 | available adapter |
@@ -967,41 +1013,20 @@ static int w83791d_detect(struct i2c_adapter *adapter, int address, int kind) | |||
967 | } | 1013 | } |
968 | 1014 | ||
969 | /* Register sysfs hooks */ | 1015 | /* Register sysfs hooks */ |
1016 | if ((err = sysfs_create_group(&client->dev.kobj, &w83791d_group))) | ||
1017 | goto error3; | ||
1018 | |||
1019 | /* Everything is ready, now register the working device */ | ||
970 | data->class_dev = hwmon_device_register(dev); | 1020 | data->class_dev = hwmon_device_register(dev); |
971 | if (IS_ERR(data->class_dev)) { | 1021 | if (IS_ERR(data->class_dev)) { |
972 | err = PTR_ERR(data->class_dev); | 1022 | err = PTR_ERR(data->class_dev); |
973 | goto error3; | 1023 | goto error4; |
974 | } | 1024 | } |
975 | 1025 | ||
976 | for (i = 0; i < NUMBER_OF_VIN; i++) { | ||
977 | device_create_file(dev, &sda_in_input[i].dev_attr); | ||
978 | device_create_file(dev, &sda_in_min[i].dev_attr); | ||
979 | device_create_file(dev, &sda_in_max[i].dev_attr); | ||
980 | } | ||
981 | |||
982 | for (i = 0; i < NUMBER_OF_FANIN; i++) { | ||
983 | device_create_file(dev, &sda_fan_input[i].dev_attr); | ||
984 | device_create_file(dev, &sda_fan_div[i].dev_attr); | ||
985 | device_create_file(dev, &sda_fan_min[i].dev_attr); | ||
986 | } | ||
987 | |||
988 | for (i = 0; i < NUMBER_OF_TEMPIN; i++) { | ||
989 | device_create_file(dev, &sda_temp_input[i].dev_attr); | ||
990 | device_create_file(dev, &sda_temp_max[i].dev_attr); | ||
991 | device_create_file(dev, &sda_temp_max_hyst[i].dev_attr); | ||
992 | } | ||
993 | |||
994 | device_create_file(dev, &dev_attr_alarms); | ||
995 | |||
996 | for (i = 0; i < ARRAY_SIZE(sda_beep_ctrl); i++) { | ||
997 | device_create_file(dev, &sda_beep_ctrl[i].dev_attr); | ||
998 | } | ||
999 | |||
1000 | device_create_file(dev, &dev_attr_cpu0_vid); | ||
1001 | device_create_file(dev, &dev_attr_vrm); | ||
1002 | |||
1003 | return 0; | 1026 | return 0; |
1004 | 1027 | ||
1028 | error4: | ||
1029 | sysfs_remove_group(&client->dev.kobj, &w83791d_group); | ||
1005 | error3: | 1030 | error3: |
1006 | if (data->lm75[0] != NULL) { | 1031 | if (data->lm75[0] != NULL) { |
1007 | i2c_detach_client(data->lm75[0]); | 1032 | i2c_detach_client(data->lm75[0]); |
@@ -1025,8 +1050,10 @@ static int w83791d_detach_client(struct i2c_client *client) | |||
1025 | int err; | 1050 | int err; |
1026 | 1051 | ||
1027 | /* main client */ | 1052 | /* main client */ |
1028 | if (data) | 1053 | if (data) { |
1029 | hwmon_device_unregister(data->class_dev); | 1054 | hwmon_device_unregister(data->class_dev); |
1055 | sysfs_remove_group(&client->dev.kobj, &w83791d_group); | ||
1056 | } | ||
1030 | 1057 | ||
1031 | if ((err = i2c_detach_client(client))) | 1058 | if ((err = i2c_detach_client(client))) |
1032 | return err; | 1059 | return err; |