vt8231: Fix unchecked return status
vt8231: Fix unchecked return status Check the return status from device_create_file() and also use the newer and cleaner sysfs creation functions. Signed-off-by: Roger Lucas <roger@planbit.co.uk> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
87808be4f9
commit
cbeeb5b7c9
1 changed files with 132 additions and 54 deletions
|
@ -451,37 +451,6 @@ define_temperature_sysfs(4);
|
||||||
define_temperature_sysfs(5);
|
define_temperature_sysfs(5);
|
||||||
define_temperature_sysfs(6);
|
define_temperature_sysfs(6);
|
||||||
|
|
||||||
#define CFG_INFO_TEMP(id) { &sensor_dev_attr_temp##id##_input.dev_attr, \
|
|
||||||
&sensor_dev_attr_temp##id##_max_hyst.dev_attr, \
|
|
||||||
&sensor_dev_attr_temp##id##_max.dev_attr }
|
|
||||||
#define CFG_INFO_VOLT(id) { &sensor_dev_attr_in##id##_input.dev_attr, \
|
|
||||||
&sensor_dev_attr_in##id##_min.dev_attr, \
|
|
||||||
&sensor_dev_attr_in##id##_max.dev_attr }
|
|
||||||
|
|
||||||
struct str_device_attr_table {
|
|
||||||
struct device_attribute *input;
|
|
||||||
struct device_attribute *min;
|
|
||||||
struct device_attribute *max;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct str_device_attr_table cfg_info_temp[] = {
|
|
||||||
{ &dev_attr_temp1_input, &dev_attr_temp1_max_hyst, &dev_attr_temp1_max },
|
|
||||||
CFG_INFO_TEMP(2),
|
|
||||||
CFG_INFO_TEMP(3),
|
|
||||||
CFG_INFO_TEMP(4),
|
|
||||||
CFG_INFO_TEMP(5),
|
|
||||||
CFG_INFO_TEMP(6)
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct str_device_attr_table cfg_info_volt[] = {
|
|
||||||
CFG_INFO_VOLT(0),
|
|
||||||
CFG_INFO_VOLT(1),
|
|
||||||
CFG_INFO_VOLT(2),
|
|
||||||
CFG_INFO_VOLT(3),
|
|
||||||
CFG_INFO_VOLT(4),
|
|
||||||
{ &dev_attr_in5_input, &dev_attr_in5_min, &dev_attr_in5_max }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Fans */
|
/* Fans */
|
||||||
static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
|
static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
|
@ -585,6 +554,107 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
|
||||||
|
|
||||||
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
|
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
|
||||||
|
|
||||||
|
static struct attribute *vt8231_attributes_temps[6][4] = {
|
||||||
|
{
|
||||||
|
&dev_attr_temp1_input.attr,
|
||||||
|
&dev_attr_temp1_max_hyst.attr,
|
||||||
|
&dev_attr_temp1_max.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_temp2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_max_hyst.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp2_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_temp3_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_max_hyst.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp3_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_temp4_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp4_max_hyst.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp4_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_temp5_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp5_max_hyst.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp5_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_temp6_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp6_max_hyst.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_temp6_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group vt8231_group_temps[6] = {
|
||||||
|
{ .attrs = vt8231_attributes_temps[0] },
|
||||||
|
{ .attrs = vt8231_attributes_temps[1] },
|
||||||
|
{ .attrs = vt8231_attributes_temps[2] },
|
||||||
|
{ .attrs = vt8231_attributes_temps[3] },
|
||||||
|
{ .attrs = vt8231_attributes_temps[4] },
|
||||||
|
{ .attrs = vt8231_attributes_temps[5] },
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *vt8231_attributes_volts[6][4] = {
|
||||||
|
{
|
||||||
|
&sensor_dev_attr_in0_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in0_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in0_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in1_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in1_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in2_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in2_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_in3_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in3_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in3_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&sensor_dev_attr_in4_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in4_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_in4_max.dev_attr.attr,
|
||||||
|
NULL
|
||||||
|
}, {
|
||||||
|
&dev_attr_in5_input.attr,
|
||||||
|
&dev_attr_in5_min.attr,
|
||||||
|
&dev_attr_in5_max.attr,
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group vt8231_group_volts[6] = {
|
||||||
|
{ .attrs = vt8231_attributes_volts[0] },
|
||||||
|
{ .attrs = vt8231_attributes_volts[1] },
|
||||||
|
{ .attrs = vt8231_attributes_volts[2] },
|
||||||
|
{ .attrs = vt8231_attributes_volts[3] },
|
||||||
|
{ .attrs = vt8231_attributes_volts[4] },
|
||||||
|
{ .attrs = vt8231_attributes_volts[5] },
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct attribute *vt8231_attributes[] = {
|
||||||
|
&sensor_dev_attr_fan1_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_input.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan1_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_min.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan1_div.dev_attr.attr,
|
||||||
|
&sensor_dev_attr_fan2_div.dev_attr.attr,
|
||||||
|
&dev_attr_alarms.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group vt8231_group = {
|
||||||
|
.attrs = vt8231_attributes,
|
||||||
|
};
|
||||||
|
|
||||||
static struct i2c_driver vt8231_driver = {
|
static struct i2c_driver vt8231_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
@ -671,43 +741,43 @@ int vt8231_detect(struct i2c_adapter *adapter)
|
||||||
vt8231_init_client(client);
|
vt8231_init_client(client);
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
data->class_dev = hwmon_device_register(&client->dev);
|
if ((err = sysfs_create_group(&client->dev.kobj, &vt8231_group)))
|
||||||
if (IS_ERR(data->class_dev)) {
|
|
||||||
err = PTR_ERR(data->class_dev);
|
|
||||||
goto exit_detach;
|
goto exit_detach;
|
||||||
}
|
|
||||||
|
|
||||||
/* Must update device information to find out the config field */
|
/* Must update device information to find out the config field */
|
||||||
data->uch_config = vt8231_read_value(client, VT8231_REG_UCH_CONFIG);
|
data->uch_config = vt8231_read_value(client, VT8231_REG_UCH_CONFIG);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(cfg_info_temp); i++) {
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_temps); i++) {
|
||||||
if (ISTEMP(i, data->uch_config)) {
|
if (ISTEMP(i, data->uch_config)) {
|
||||||
device_create_file(&client->dev,
|
if ((err = sysfs_create_group(&client->dev.kobj,
|
||||||
cfg_info_temp[i].input);
|
&vt8231_group_temps[i])))
|
||||||
device_create_file(&client->dev, cfg_info_temp[i].max);
|
goto exit_remove_files;
|
||||||
device_create_file(&client->dev, cfg_info_temp[i].min);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(cfg_info_volt); i++) {
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_volts); i++) {
|
||||||
if (ISVOLT(i, data->uch_config)) {
|
if (ISVOLT(i, data->uch_config)) {
|
||||||
device_create_file(&client->dev,
|
if ((err = sysfs_create_group(&client->dev.kobj,
|
||||||
cfg_info_volt[i].input);
|
&vt8231_group_volts[i])))
|
||||||
device_create_file(&client->dev, cfg_info_volt[i].max);
|
goto exit_remove_files;
|
||||||
device_create_file(&client->dev, cfg_info_volt[i].min);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan1_input.dev_attr);
|
data->class_dev = hwmon_device_register(&client->dev);
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan2_input.dev_attr);
|
if (IS_ERR(data->class_dev)) {
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan1_min.dev_attr);
|
err = PTR_ERR(data->class_dev);
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan2_min.dev_attr);
|
goto exit_remove_files;
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan1_div.dev_attr);
|
}
|
||||||
device_create_file(&client->dev, &sensor_dev_attr_fan2_div.dev_attr);
|
|
||||||
|
|
||||||
device_create_file(&client->dev, &dev_attr_alarms);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
exit_remove_files:
|
||||||
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_volts); i++)
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group_volts[i]);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_temps); i++)
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group_temps[i]);
|
||||||
|
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group);
|
||||||
exit_detach:
|
exit_detach:
|
||||||
i2c_detach_client(client);
|
i2c_detach_client(client);
|
||||||
exit_free:
|
exit_free:
|
||||||
|
@ -720,10 +790,18 @@ int vt8231_detect(struct i2c_adapter *adapter)
|
||||||
static int vt8231_detach_client(struct i2c_client *client)
|
static int vt8231_detach_client(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct vt8231_data *data = i2c_get_clientdata(client);
|
struct vt8231_data *data = i2c_get_clientdata(client);
|
||||||
int err;
|
int err, i;
|
||||||
|
|
||||||
hwmon_device_unregister(data->class_dev);
|
hwmon_device_unregister(data->class_dev);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_volts); i++)
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group_volts[i]);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(vt8231_group_temps); i++)
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group_temps[i]);
|
||||||
|
|
||||||
|
sysfs_remove_group(&client->dev.kobj, &vt8231_group);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client))) {
|
if ((err = i2c_detach_client(client))) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue