Commit 681c6f7a authored by Mark M. Hoffman's avatar Mark M. Hoffman Committed by Greg Kroah-Hartman

hwmon: Fix unchecked return status, batch 3

hwmon: Fix unchecked return status, batch 3

Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0501a381
...@@ -190,6 +190,21 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter) ...@@ -190,6 +190,21 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter)
return i2c_probe(adapter, &addr_data, adm1021_detect); return i2c_probe(adapter, &addr_data, adm1021_detect);
} }
static struct attribute *adm1021_attributes[] = {
&dev_attr_temp1_max.attr,
&dev_attr_temp1_min.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp2_max.attr,
&dev_attr_temp2_min.attr,
&dev_attr_temp2_input.attr,
&dev_attr_alarms.attr,
NULL
};
static const struct attribute_group adm1021_group = {
.attrs = adm1021_attributes,
};
static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
int i; int i;
...@@ -287,22 +302,19 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -287,22 +302,19 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
adm1021_init_client(new_client); adm1021_init_client(new_client);
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1021_group)))
goto error2;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto error2; goto error3;
} }
device_create_file(&new_client->dev, &dev_attr_temp1_max);
device_create_file(&new_client->dev, &dev_attr_temp1_min);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev, &dev_attr_temp2_max);
device_create_file(&new_client->dev, &dev_attr_temp2_min);
device_create_file(&new_client->dev, &dev_attr_temp2_input);
device_create_file(&new_client->dev, &dev_attr_alarms);
return 0; return 0;
error3:
sysfs_remove_group(&new_client->dev.kobj, &adm1021_group);
error2: error2:
i2c_detach_client(new_client); i2c_detach_client(new_client);
error1: error1:
...@@ -326,6 +338,7 @@ static int adm1021_detach_client(struct i2c_client *client) ...@@ -326,6 +338,7 @@ static int adm1021_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &adm1021_group);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
...@@ -315,6 +315,49 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter) ...@@ -315,6 +315,49 @@ static int adm1025_attach_adapter(struct i2c_adapter *adapter)
return i2c_probe(adapter, &addr_data, adm1025_detect); return i2c_probe(adapter, &addr_data, adm1025_detect);
} }
static struct attribute *adm1025_attributes[] = {
&dev_attr_in0_input.attr,
&dev_attr_in1_input.attr,
&dev_attr_in2_input.attr,
&dev_attr_in3_input.attr,
&dev_attr_in5_input.attr,
&dev_attr_in0_min.attr,
&dev_attr_in1_min.attr,
&dev_attr_in2_min.attr,
&dev_attr_in3_min.attr,
&dev_attr_in5_min.attr,
&dev_attr_in0_max.attr,
&dev_attr_in1_max.attr,
&dev_attr_in2_max.attr,
&dev_attr_in3_max.attr,
&dev_attr_in5_max.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp1_min.attr,
&dev_attr_temp2_min.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp2_max.attr,
&dev_attr_alarms.attr,
&dev_attr_cpu0_vid.attr,
&dev_attr_vrm.attr,
NULL
};
static const struct attribute_group adm1025_group = {
.attrs = adm1025_attributes,
};
static struct attribute *adm1025_attributes_opt[] = {
&dev_attr_in4_input.attr,
&dev_attr_in4_min.attr,
&dev_attr_in4_max.attr,
NULL
};
static const struct attribute_group adm1025_group_opt = {
.attrs = adm1025_attributes_opt,
};
/* /*
* The following function does more than just detection. If detection * The following function does more than just detection. If detection
* succeeds, it also registers the new chip. * succeeds, it also registers the new chip.
...@@ -415,46 +458,31 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -415,46 +458,31 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
adm1025_init_client(new_client); adm1025_init_client(new_client);
/* Register sysfs hooks */ /* Register sysfs hooks */
data->class_dev = hwmon_device_register(&new_client->dev); if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1025_group)))
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto exit_detach; goto exit_detach;
}
device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in1_input);
device_create_file(&new_client->dev, &dev_attr_in2_input);
device_create_file(&new_client->dev, &dev_attr_in3_input);
device_create_file(&new_client->dev, &dev_attr_in5_input);
device_create_file(&new_client->dev, &dev_attr_in0_min);
device_create_file(&new_client->dev, &dev_attr_in1_min);
device_create_file(&new_client->dev, &dev_attr_in2_min);
device_create_file(&new_client->dev, &dev_attr_in3_min);
device_create_file(&new_client->dev, &dev_attr_in5_min);
device_create_file(&new_client->dev, &dev_attr_in0_max);
device_create_file(&new_client->dev, &dev_attr_in1_max);
device_create_file(&new_client->dev, &dev_attr_in2_max);
device_create_file(&new_client->dev, &dev_attr_in3_max);
device_create_file(&new_client->dev, &dev_attr_in5_max);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev, &dev_attr_temp2_input);
device_create_file(&new_client->dev, &dev_attr_temp1_min);
device_create_file(&new_client->dev, &dev_attr_temp2_min);
device_create_file(&new_client->dev, &dev_attr_temp1_max);
device_create_file(&new_client->dev, &dev_attr_temp2_max);
device_create_file(&new_client->dev, &dev_attr_alarms);
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
device_create_file(&new_client->dev, &dev_attr_vrm);
/* Pin 11 is either in4 (+12V) or VID4 */ /* Pin 11 is either in4 (+12V) or VID4 */
if (!(config & 0x20)) { if (!(config & 0x20)) {
device_create_file(&new_client->dev, &dev_attr_in4_input); if ((err = device_create_file(&new_client->dev,
device_create_file(&new_client->dev, &dev_attr_in4_min); &dev_attr_in4_input))
device_create_file(&new_client->dev, &dev_attr_in4_max); || (err = device_create_file(&new_client->dev,
&dev_attr_in4_min))
|| (err = device_create_file(&new_client->dev,
&dev_attr_in4_max)))
goto exit_remove;
}
data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto exit_remove;
} }
return 0; return 0;
exit_remove:
sysfs_remove_group(&new_client->dev.kobj, &adm1025_group);
sysfs_remove_group(&new_client->dev.kobj, &adm1025_group_opt);
exit_detach: exit_detach:
i2c_detach_client(new_client); i2c_detach_client(new_client);
exit_free: exit_free:
...@@ -511,6 +539,8 @@ static int adm1025_detach_client(struct i2c_client *client) ...@@ -511,6 +539,8 @@ static int adm1025_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &adm1025_group);
sysfs_remove_group(&client->dev.kobj, &adm1025_group_opt);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
This diff is collapsed.
...@@ -730,6 +730,61 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter) ...@@ -730,6 +730,61 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter)
return i2c_probe(adapter, &addr_data, adm1031_detect); return i2c_probe(adapter, &addr_data, adm1031_detect);
} }
static struct attribute *adm1031_attributes[] = {
&dev_attr_fan1_input.attr,
&dev_attr_fan1_div.attr,
&dev_attr_fan1_min.attr,
&dev_attr_pwm1.attr,
&dev_attr_auto_fan1_channel.attr,
&dev_attr_temp1_input.attr,
&dev_attr_temp1_min.attr,
&dev_attr_temp1_max.attr,
&dev_attr_temp1_crit.attr,
&dev_attr_temp2_input.attr,
&dev_attr_temp2_min.attr,
&dev_attr_temp2_max.attr,
&dev_attr_temp2_crit.attr,
&dev_attr_auto_temp1_off.attr,
&dev_attr_auto_temp1_min.attr,
&dev_attr_auto_temp1_max.attr,
&dev_attr_auto_temp2_off.attr,
&dev_attr_auto_temp2_min.attr,
&dev_attr_auto_temp2_max.attr,
&dev_attr_auto_fan1_min_pwm.attr,
&dev_attr_alarms.attr,
NULL
};
static const struct attribute_group adm1031_group = {
.attrs = adm1031_attributes,
};
static struct attribute *adm1031_attributes_opt[] = {
&dev_attr_fan2_input.attr,
&dev_attr_fan2_div.attr,
&dev_attr_fan2_min.attr,
&dev_attr_pwm2.attr,
&dev_attr_auto_fan2_channel.attr,
&dev_attr_temp3_input.attr,
&dev_attr_temp3_min.attr,
&dev_attr_temp3_max.attr,
&dev_attr_temp3_crit.attr,
&dev_attr_auto_temp3_off.attr,
&dev_attr_auto_temp3_min.attr,
&dev_attr_auto_temp3_max.attr,
&dev_attr_auto_fan2_min_pwm.attr,
NULL
};
static const struct attribute_group adm1031_group_opt = {
.attrs = adm1031_attributes_opt,
};
/* This function is called by i2c_probe */ /* This function is called by i2c_probe */
static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
...@@ -789,57 +844,26 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -789,57 +844,26 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
adm1031_init_client(new_client); adm1031_init_client(new_client);
/* Register sysfs hooks */ /* Register sysfs hooks */
data->class_dev = hwmon_device_register(&new_client->dev); if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1031_group)))
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto exit_detach; goto exit_detach;
}
device_create_file(&new_client->dev, &dev_attr_fan1_input);
device_create_file(&new_client->dev, &dev_attr_fan1_div);
device_create_file(&new_client->dev, &dev_attr_fan1_min);
device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_auto_fan1_channel);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev, &dev_attr_temp1_min);
device_create_file(&new_client->dev, &dev_attr_temp1_max);
device_create_file(&new_client->dev, &dev_attr_temp1_crit);
device_create_file(&new_client->dev, &dev_attr_temp2_input);
device_create_file(&new_client->dev, &dev_attr_temp2_min);
device_create_file(&new_client->dev, &dev_attr_temp2_max);
device_create_file(&new_client->dev, &dev_attr_temp2_crit);
device_create_file(&new_client->dev, &dev_attr_auto_temp1_off);
device_create_file(&new_client->dev, &dev_attr_auto_temp1_min);
device_create_file(&new_client->dev, &dev_attr_auto_temp1_max);
device_create_file(&new_client->dev, &dev_attr_auto_temp2_off);
device_create_file(&new_client->dev, &dev_attr_auto_temp2_min);
device_create_file(&new_client->dev, &dev_attr_auto_temp2_max);
device_create_file(&new_client->dev, &dev_attr_auto_fan1_min_pwm);
device_create_file(&new_client->dev, &dev_attr_alarms);
if (kind == adm1031) { if (kind == adm1031) {
device_create_file(&new_client->dev, &dev_attr_fan2_input); if ((err = sysfs_create_group(&new_client->dev.kobj,
device_create_file(&new_client->dev, &dev_attr_fan2_div); &adm1031_group_opt)))
device_create_file(&new_client->dev, &dev_attr_fan2_min); goto exit_remove;
device_create_file(&new_client->dev, &dev_attr_pwm2); }
device_create_file(&new_client->dev,
&dev_attr_auto_fan2_channel); data->class_dev = hwmon_device_register(&new_client->dev);
device_create_file(&new_client->dev, &dev_attr_temp3_input); if (IS_ERR(data->class_dev)) {
device_create_file(&new_client->dev, &dev_attr_temp3_min); err = PTR_ERR(data->class_dev);
device_create_file(&new_client->dev, &dev_attr_temp3_max); goto exit_remove;
device_create_file(&new_client->dev, &dev_attr_temp3_crit);
device_create_file(&new_client->dev, &dev_attr_auto_temp3_off);
device_create_file(&new_client->dev, &dev_attr_auto_temp3_min);
device_create_file(&new_client->dev, &dev_attr_auto_temp3_max);
device_create_file(&new_client->dev, &dev_attr_auto_fan2_min_pwm);
} }
return 0; return 0;
exit_remove:
sysfs_remove_group(&new_client->dev.kobj, &adm1031_group);
sysfs_remove_group(&new_client->dev.kobj, &adm1031_group_opt);
exit_detach: exit_detach:
i2c_detach_client(new_client); i2c_detach_client(new_client);
exit_free: exit_free:
...@@ -854,6 +878,8 @@ static int adm1031_detach_client(struct i2c_client *client) ...@@ -854,6 +878,8 @@ static int adm1031_detach_client(struct i2c_client *client)
int ret; int ret;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &adm1031_group);
sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
if ((ret = i2c_detach_client(client)) != 0) { if ((ret = i2c_detach_client(client)) != 0) {
return ret; return ret;
} }
......
...@@ -465,6 +465,45 @@ static ssize_t chassis_clear(struct device *dev, ...@@ -465,6 +465,45 @@ static ssize_t chassis_clear(struct device *dev,
} }
static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear);
static struct attribute *adm9240_attributes[] = {
&sensor_dev_attr_in0_input.dev_attr.attr,
&sensor_dev_attr_in0_min.dev_attr.attr,
&sensor_dev_attr_in0_max.dev_attr.attr,
&sensor_dev_attr_in1_input.dev_attr.attr,
&sensor_dev_attr_in1_min.dev_attr.attr,
&sensor_dev_attr_in1_max.dev_attr.attr,
&sensor_dev_attr_in2_input.dev_attr.attr,
&sensor_dev_attr_in2_min.dev_attr.attr,
&sensor_dev_attr_in2_max.dev_attr.attr,
&sensor_dev_attr_in3_input.dev_attr.attr,
&sensor_dev_attr_in3_min.dev_attr.attr,
&sensor_dev_attr_in3_max.dev_attr.attr,
&sensor_dev_attr_in4_input.dev_attr.attr,
&sensor_dev_attr_in4_min.dev_attr.attr,
&sensor_dev_attr_in4_max.dev_attr.attr,
&sensor_dev_attr_in5_input.dev_attr.attr,
&sensor_dev_attr_in5_min.dev_attr.attr,
&sensor_dev_attr_in5_max.dev_attr.attr,
&dev_attr_temp1_input.attr,
&sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
&sensor_dev_attr_fan1_input.dev_attr.attr,
&sensor_dev_attr_fan1_div.dev_attr.attr,
&sensor_dev_attr_fan1_min.dev_attr.attr,
&sensor_dev_attr_fan2_input.dev_attr.attr,
&sensor_dev_attr_fan2_div.dev_attr.attr,
&sensor_dev_attr_fan2_min.dev_attr.attr,
&dev_attr_alarms.attr,
&dev_attr_aout_output.attr,
&dev_attr_chassis_clear.attr,
&dev_attr_cpu0_vid.attr,
NULL
};
static const struct attribute_group adm9240_group = {
.attrs = adm9240_attributes,
};
/*** sensor chip detect and driver install ***/ /*** sensor chip detect and driver install ***/
...@@ -548,72 +587,19 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -548,72 +587,19 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
adm9240_init_client(new_client); adm9240_init_client(new_client);
/* populate sysfs filesystem */ /* populate sysfs filesystem */
if ((err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group)))
goto exit_detach;
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto exit_detach; goto exit_remove;
} }
device_create_file(&new_client->dev,
&sensor_dev_attr_in0_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in0_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in0_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in1_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in1_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in1_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in2_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in2_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in2_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in3_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in3_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in3_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in4_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in4_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in4_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in5_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in5_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_in5_max.dev_attr);
device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_max.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_max_hyst.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_div.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan1_min.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan2_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan2_div.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_fan2_min.dev_attr);
device_create_file(&new_client->dev, &dev_attr_alarms);
device_create_file(&new_client->dev, &dev_attr_aout_output);
device_create_file(&new_client->dev, &dev_attr_chassis_clear);
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
return 0; return 0;
exit_remove:
sysfs_remove_group(&new_client->dev.kobj, &adm9240_group);
exit_detach: exit_detach:
i2c_detach_client(new_client); i2c_detach_client(new_client);
exit_free: exit_free:
...@@ -635,6 +621,7 @@ static int adm9240_detach_client(struct i2c_client *client) ...@@ -635,6 +621,7 @@ static int adm9240_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
sysfs_remove_group(&client->dev.kobj, &adm9240_group);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment