Commit f3722d5b authored by Jim Cromie's avatar Jim Cromie Committed by Greg Kroah-Hartman

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: default avatarJim Cromie <jim.cromie@gmail.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 941c5c05
...@@ -1018,60 +1018,69 @@ static int pc87360_detect(struct i2c_adapter *adapter) ...@@ -1018,60 +1018,69 @@ static int pc87360_detect(struct i2c_adapter *adapter)
pc87360_init_client(client, use_thermistors); pc87360_init_client(client, use_thermistors);
} }
/* Register sysfs hooks */ /* Register all-or-nothing sysfs groups */
data->class_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->class_dev)) { if (data->innr &&
err = PTR_ERR(data->class_dev); (err = sysfs_create_group(&client->dev.kobj,
&pc8736x_vin_group)))
goto ERROR3; goto ERROR3;
}
if (data->innr) { if (data->innr == 14 &&
for (i = 0; i < 11; i++) { (err = sysfs_create_group(&client->dev.kobj,
device_create_file(dev, &in_input[i].dev_attr); &pc8736x_therm_group)))
device_create_file(dev, &in_min[i].dev_attr); goto ERROR3;
device_create_file(dev, &in_max[i].dev_attr);
device_create_file(dev, &in_status[i].dev_attr); /* create device attr-files for varying sysfs groups */
}
device_create_file(dev, &dev_attr_cpu0_vid);
device_create_file(dev, &dev_attr_vrm);
device_create_file(dev, &dev_attr_alarms_in);
}
if (data->tempnr) { if (data->tempnr) {
for (i = 0; i < data->tempnr; i++) { for (i = 0; i < data->tempnr; i++) {
device_create_file(dev, &temp_input[i].dev_attr); if ((err = device_create_file(dev,
device_create_file(dev, &temp_min[i].dev_attr); &temp_input[i].dev_attr))
device_create_file(dev, &temp_max[i].dev_attr); || (err = device_create_file(dev,
device_create_file(dev, &temp_crit[i].dev_attr); &temp_min[i].dev_attr))
device_create_file(dev, &temp_status[i].dev_attr); || (err = device_create_file(dev,
} &temp_max[i].dev_attr))
device_create_file(dev, &dev_attr_alarms_temp); || (err = device_create_file(dev,
} &temp_crit[i].dev_attr))
|| (err = device_create_file(dev,
if (data->innr == 14) { &temp_status[i].dev_attr)))
for (i = 0; i < 3; i++) { goto ERROR3;
device_create_file(dev, &therm_input[i].dev_attr);
device_create_file(dev, &therm_min[i].dev_attr);
device_create_file(dev, &therm_max[i].dev_attr);
device_create_file(dev, &therm_crit[i].dev_attr);
device_create_file(dev, &therm_status[i].dev_attr);
} }
if ((err = device_create_file(dev, &dev_attr_alarms_temp)))
goto ERROR3;
} }
for (i = 0; i < data->fannr; i++) { for (i = 0; i < data->fannr; i++) {
if (FAN_CONFIG_MONITOR(data->fan_conf, i)) { if (FAN_CONFIG_MONITOR(data->fan_conf, i)
device_create_file(dev, &fan_input[i].dev_attr); && ((err = device_create_file(dev,
device_create_file(dev, &fan_min[i].dev_attr); &fan_input[i].dev_attr))
device_create_file(dev, &fan_div[i].dev_attr); || (err = device_create_file(dev,
device_create_file(dev, &fan_status[i].dev_attr); &fan_min[i].dev_attr))
} || (err = device_create_file(dev,
if (FAN_CONFIG_CONTROL(data->fan_conf, i)) &fan_div[i].dev_attr))
device_create_file(dev, &pwm[i].dev_attr); || (err = device_create_file(dev,
&fan_status[i].dev_attr))))
goto ERROR3;
if (FAN_CONFIG_CONTROL(data->fan_conf, i)
&& (err = device_create_file(dev, &pwm[i].dev_attr)))
goto ERROR3;
} }
data->class_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto ERROR3;
}
return 0; return 0;
ERROR3: ERROR3:
/* can still remove groups whose members were added individually */
sysfs_remove_group(&client->dev.kobj, &pc8736x_temp_group);
sysfs_remove_group(&client->dev.kobj, &pc8736x_fan_group);
sysfs_remove_group(&client->dev.kobj, &pc8736x_therm_group);
sysfs_remove_group(&client->dev.kobj, &pc8736x_vin_group);
i2c_detach_client(client); i2c_detach_client(client);
ERROR2: ERROR2:
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
......
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