diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2006-09-24 15:03:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:17 -0400 |
commit | f3722d5b6a474e31237d23980e9bd38facfda6f4 (patch) | |
tree | 68cf55a62cad0e4ea98e861e13c1fa184333c24c /drivers/hwmon/pc87360.c | |
parent | 941c5c05cf38da5e12d70edc5d0fec5c24bce8b6 (diff) |
pc87360: Check for error on sysfs files creation
pc87360: Check for error on sysfs files creation
Use sysfs_create_group() for 2 sensor-types which are chip-model
invariant, i.e. all-or-nothing attribute groups.
Other 2 groups vary too much due to configuration, etc, so we keep the
loops of device_create_file(), but now check their returns.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/pc87360.c')
-rw-r--r-- | drivers/hwmon/pc87360.c | 89 |
1 files changed, 49 insertions, 40 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index ce3232c75ae1..3b8b81984ad4 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -1018,60 +1018,69 @@ static int pc87360_detect(struct i2c_adapter *adapter) | |||
1018 | pc87360_init_client(client, use_thermistors); | 1018 | pc87360_init_client(client, use_thermistors); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | /* Register sysfs hooks */ | 1021 | /* Register all-or-nothing sysfs groups */ |
1022 | data->class_dev = hwmon_device_register(&client->dev); | 1022 | |
1023 | if (IS_ERR(data->class_dev)) { | 1023 | if (data->innr && |
1024 | err = PTR_ERR(data->class_dev); | 1024 | (err = sysfs_create_group(&client->dev.kobj, |
1025 | &pc8736x_vin_group))) | ||
1025 | goto ERROR3; | 1026 | goto ERROR3; |
1026 | } | ||
1027 | 1027 | ||
1028 | if (data->innr) { | 1028 | if (data->innr == 14 && |
1029 | for (i = 0; i < 11; i++) { | 1029 | (err = sysfs_create_group(&client->dev.kobj, |
1030 | device_create_file(dev, &in_input[i].dev_attr); | 1030 | &pc8736x_therm_group))) |
1031 | device_create_file(dev, &in_min[i].dev_attr); | 1031 | goto ERROR3; |
1032 | device_create_file(dev, &in_max[i].dev_attr); | 1032 | |
1033 | device_create_file(dev, &in_status[i].dev_attr); | 1033 | /* create device attr-files for varying sysfs groups */ |
1034 | } | ||
1035 | device_create_file(dev, &dev_attr_cpu0_vid); | ||
1036 | device_create_file(dev, &dev_attr_vrm); | ||
1037 | device_create_file(dev, &dev_attr_alarms_in); | ||
1038 | } | ||
1039 | 1034 | ||
1040 | if (data->tempnr) { | 1035 | if (data->tempnr) { |
1041 | for (i = 0; i < data->tempnr; i++) { | 1036 | for (i = 0; i < data->tempnr; i++) { |
1042 | device_create_file(dev, &temp_input[i].dev_attr); | 1037 | if ((err = device_create_file(dev, |
1043 | device_create_file(dev, &temp_min[i].dev_attr); | 1038 | &temp_input[i].dev_attr)) |
1044 | device_create_file(dev, &temp_max[i].dev_attr); | 1039 | || (err = device_create_file(dev, |
1045 | device_create_file(dev, &temp_crit[i].dev_attr); | 1040 | &temp_min[i].dev_attr)) |
1046 | device_create_file(dev, &temp_status[i].dev_attr); | 1041 | || (err = device_create_file(dev, |
1047 | } | 1042 | &temp_max[i].dev_attr)) |
1048 | device_create_file(dev, &dev_attr_alarms_temp); | 1043 | || (err = device_create_file(dev, |
1049 | } | 1044 | &temp_crit[i].dev_attr)) |
1050 | 1045 | || (err = device_create_file(dev, | |
1051 | if (data->innr == 14) { | 1046 | &temp_status[i].dev_attr))) |
1052 | for (i = 0; i < 3; i++) { | 1047 | goto ERROR3; |
1053 | device_create_file(dev, &therm_input[i].dev_attr); | ||
1054 | device_create_file(dev, &therm_min[i].dev_attr); | ||
1055 | device_create_file(dev, &therm_max[i].dev_attr); | ||
1056 | device_create_file(dev, &therm_crit[i].dev_attr); | ||
1057 | device_create_file(dev, &therm_status[i].dev_attr); | ||
1058 | } | 1048 | } |
1049 | if ((err = device_create_file(dev, &dev_attr_alarms_temp))) | ||
1050 | goto ERROR3; | ||
1059 | } | 1051 | } |
1060 | 1052 | ||
1061 | for (i = 0; i < data->fannr; i++) { | 1053 | for (i = 0; i < data->fannr; i++) { |
1062 | if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { | 1054 | if (FAN_CONFIG_MONITOR(data->fan_conf, i) |
1063 | device_create_file(dev, &fan_input[i].dev_attr); | 1055 | && ((err = device_create_file(dev, |
1064 | device_create_file(dev, &fan_min[i].dev_attr); | 1056 | &fan_input[i].dev_attr)) |
1065 | device_create_file(dev, &fan_div[i].dev_attr); | 1057 | || (err = device_create_file(dev, |
1066 | device_create_file(dev, &fan_status[i].dev_attr); | 1058 | &fan_min[i].dev_attr)) |
1067 | } | 1059 | || (err = device_create_file(dev, |
1068 | if (FAN_CONFIG_CONTROL(data->fan_conf, i)) | 1060 | &fan_div[i].dev_attr)) |
1069 | device_create_file(dev, &pwm[i].dev_attr); | 1061 | || (err = device_create_file(dev, |
1062 | &fan_status[i].dev_attr)))) | ||
1063 | goto ERROR3; | ||
1064 | |||
1065 | if (FAN_CONFIG_CONTROL(data->fan_conf, i) | ||
1066 | && (err = device_create_file(dev, &pwm[i].dev_attr))) | ||
1067 | goto ERROR3; | ||
1070 | } | 1068 | } |
1071 | 1069 | ||
1070 | data->class_dev = hwmon_device_register(&client->dev); | ||
1071 | if (IS_ERR(data->class_dev)) { | ||
1072 | err = PTR_ERR(data->class_dev); | ||
1073 | goto ERROR3; | ||
1074 | } | ||
1072 | return 0; | 1075 | return 0; |
1073 | 1076 | ||
1074 | ERROR3: | 1077 | ERROR3: |
1078 | /* can still remove groups whose members were added individually */ | ||
1079 | sysfs_remove_group(&client->dev.kobj, &pc8736x_temp_group); | ||
1080 | sysfs_remove_group(&client->dev.kobj, &pc8736x_fan_group); | ||
1081 | sysfs_remove_group(&client->dev.kobj, &pc8736x_therm_group); | ||
1082 | sysfs_remove_group(&client->dev.kobj, &pc8736x_vin_group); | ||
1083 | |||
1075 | i2c_detach_client(client); | 1084 | i2c_detach_client(client); |
1076 | ERROR2: | 1085 | ERROR2: |
1077 | for (i = 0; i < 3; i++) { | 1086 | for (i = 0; i < 3; i++) { |