This is a note to let you know that I've just added the patch titled Subject: [PATCH 13/23] hwmon: Fix unchecked return status, batch 2 to my gregkh-2.6 tree. Its filename is hwmon-unchecked-return-status-fixes-2.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ >From khali at linux-fr.org Sun Sep 24 12:14:43 2006 Date: Sun, 24 Sep 2006 21:14:35 +0200 From: Jean Delvare <khali at linux-fr.org> To: Greg KH <greg at kroah.com> Cc: LM Sensors <lm-sensors at lm-sensors.org>, "Mark M. Hoffman" <mhoffman at lightlink.com> Subject: [PATCH 13/23] hwmon: Fix unchecked return status, batch 2 Message-Id: <20060924211435.d4bc82c3.khali at linux-fr.org> Content-Disposition: inline; filename=hwmon-unchecked-return-status-fixes-2.patch From: "Mark M. Hoffman" <mhoffman at lightlink.com> hwmon: Fix unchecked return status, batch 2 Fix up some hwmon drivers so that they no longer ignore return status from device_create_file(). Signed-off-by: Mark M. Hoffman <mhoffman at lightlink.com> Signed-off-by: Jean Delvare <khali at linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de> --- drivers/hwmon/lm77.c | 33 ++++++-- drivers/hwmon/lm80.c | 85 +++++++++++++--------- drivers/hwmon/lm85.c | 173 +++++++++++++++++++++++++++------------------- drivers/hwmon/lm87.c | 191 +++++++++++++++++++++++++++++++++++++-------------- drivers/hwmon/lm92.c | 34 ++++++--- 5 files changed, 338 insertions(+), 178 deletions(-) --- gregkh-2.6.orig/drivers/hwmon/lm77.c +++ gregkh-2.6/drivers/hwmon/lm77.c @@ -212,6 +212,23 @@ static int lm77_attach_adapter(struct i2 return i2c_probe(adapter, &addr_data, lm77_detect); } +static struct attribute *lm77_attributes[] = { + &dev_attr_temp1_input.attr, + &dev_attr_temp1_crit.attr, + &dev_attr_temp1_min.attr, + &dev_attr_temp1_max.attr, + &dev_attr_temp1_crit_hyst.attr, + &dev_attr_temp1_min_hyst.attr, + &dev_attr_temp1_max_hyst.attr, + &dev_attr_alarms.attr, + + NULL +}; + +static const struct attribute_group lm77_group = { + .attrs = lm77_attributes, +}; + /* This function is called by i2c_probe */ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) { @@ -317,22 +334,19 @@ static int lm77_detect(struct i2c_adapte lm77_init_client(new_client); /* Register sysfs hooks */ + if ((err = sysfs_create_group(&new_client->dev.kobj, &lm77_group))) + goto exit_detach; + data->class_dev = hwmon_device_register(&new_client->dev); if (IS_ERR(data->class_dev)) { err = PTR_ERR(data->class_dev); - goto exit_detach; + goto exit_remove; } - device_create_file(&new_client->dev, &dev_attr_temp1_input); - device_create_file(&new_client->dev, &dev_attr_temp1_crit); - 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_hyst); - device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst); - device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); - device_create_file(&new_client->dev, &dev_attr_alarms); return 0; +exit_remove: + sysfs_remove_group(&new_client->dev.kobj, &lm77_group); exit_detach: i2c_detach_client(new_client); exit_free: @@ -345,6 +359,7 @@ static int lm77_detach_client(struct i2c { struct lm77_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &lm77_group); i2c_detach_client(client); kfree(data); return 0; --- gregkh-2.6.orig/drivers/hwmon/lm80.c +++ gregkh-2.6/drivers/hwmon/lm80.c @@ -394,6 +394,48 @@ static int lm80_attach_adapter(struct i2 return i2c_probe(adapter, &addr_data, lm80_detect); } +static struct attribute *lm80_attributes[] = { + &dev_attr_in0_min.attr, + &dev_attr_in1_min.attr, + &dev_attr_in2_min.attr, + &dev_attr_in3_min.attr, + &dev_attr_in4_min.attr, + &dev_attr_in5_min.attr, + &dev_attr_in6_min.attr, + &dev_attr_in0_max.attr, + &dev_attr_in1_max.attr, + &dev_attr_in2_max.attr, + &dev_attr_in3_max.attr, + &dev_attr_in4_max.attr, + &dev_attr_in5_max.attr, + &dev_attr_in6_max.attr, + &dev_attr_in0_input.attr, + &dev_attr_in1_input.attr, + &dev_attr_in2_input.attr, + &dev_attr_in3_input.attr, + &dev_attr_in4_input.attr, + &dev_attr_in5_input.attr, + &dev_attr_in6_input.attr, + &dev_attr_fan1_min.attr, + &dev_attr_fan2_min.attr, + &dev_attr_fan1_input.attr, + &dev_attr_fan2_input.attr, + &dev_attr_fan1_div.attr, + &dev_attr_fan2_div.attr, + &dev_attr_temp1_input.attr, + &dev_attr_temp1_max.attr, + &dev_attr_temp1_max_hyst.attr, + &dev_attr_temp1_crit.attr, + &dev_attr_temp1_crit_hyst.attr, + &dev_attr_alarms.attr, + + NULL +}; + +static const struct attribute_group lm80_group = { + .attrs = lm80_attributes, +}; + static int lm80_detect(struct i2c_adapter *adapter, int address, int kind) { int i, cur; @@ -452,48 +494,19 @@ static int lm80_detect(struct i2c_adapte data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2)); /* Register sysfs hooks */ + if ((err = sysfs_create_group(&new_client->dev.kobj, &lm80_group))) + goto error_detach; + data->class_dev = hwmon_device_register(&new_client->dev); if (IS_ERR(data->class_dev)) { err = PTR_ERR(data->class_dev); - goto error_detach; + goto error_remove; } - 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_in4_min); - device_create_file(&new_client->dev, &dev_attr_in5_min); - device_create_file(&new_client->dev, &dev_attr_in6_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_in4_max); - device_create_file(&new_client->dev, &dev_attr_in5_max); - device_create_file(&new_client->dev, &dev_attr_in6_max); - 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_in4_input); - device_create_file(&new_client->dev, &dev_attr_in5_input); - device_create_file(&new_client->dev, &dev_attr_in6_input); - device_create_file(&new_client->dev, &dev_attr_fan1_min); - device_create_file(&new_client->dev, &dev_attr_fan2_min); - device_create_file(&new_client->dev, &dev_attr_fan1_input); - device_create_file(&new_client->dev, &dev_attr_fan2_input); - device_create_file(&new_client->dev, &dev_attr_fan1_div); - device_create_file(&new_client->dev, &dev_attr_fan2_div); - device_create_file(&new_client->dev, &dev_attr_temp1_input); - device_create_file(&new_client->dev, &dev_attr_temp1_max); - device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); - device_create_file(&new_client->dev, &dev_attr_temp1_crit); - device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); - device_create_file(&new_client->dev, &dev_attr_alarms); - return 0; +error_remove: + sysfs_remove_group(&new_client->dev.kobj, &lm80_group); error_detach: i2c_detach_client(new_client); error_free: @@ -508,7 +521,7 @@ static int lm80_detach_client(struct i2c int err; hwmon_device_unregister(data->class_dev); - + sysfs_remove_group(&client->dev.kobj, &lm80_group); if ((err = i2c_detach_client(client))) return err; --- gregkh-2.6.orig/drivers/hwmon/lm85.c +++ gregkh-2.6/drivers/hwmon/lm85.c @@ -1025,6 +1025,89 @@ static int lm85_attach_adapter(struct i2 return i2c_probe(adapter, &addr_data, lm85_detect); } +static struct attribute *lm85_attributes[] = { + &dev_attr_fan1_input.attr, + &dev_attr_fan2_input.attr, + &dev_attr_fan3_input.attr, + &dev_attr_fan4_input.attr, + &dev_attr_fan1_min.attr, + &dev_attr_fan2_min.attr, + &dev_attr_fan3_min.attr, + &dev_attr_fan4_min.attr, + &dev_attr_pwm1.attr, + &dev_attr_pwm2.attr, + &dev_attr_pwm3.attr, + &dev_attr_pwm1_enable.attr, + &dev_attr_pwm2_enable.attr, + &dev_attr_pwm3_enable.attr, + &dev_attr_in0_input.attr, + &dev_attr_in1_input.attr, + &dev_attr_in2_input.attr, + &dev_attr_in3_input.attr, + &dev_attr_in0_min.attr, + &dev_attr_in1_min.attr, + &dev_attr_in2_min.attr, + &dev_attr_in3_min.attr, + &dev_attr_in0_max.attr, + &dev_attr_in1_max.attr, + &dev_attr_in2_max.attr, + &dev_attr_in3_max.attr, + &dev_attr_temp1_input.attr, + &dev_attr_temp2_input.attr, + &dev_attr_temp3_input.attr, + &dev_attr_temp1_min.attr, + &dev_attr_temp2_min.attr, + &dev_attr_temp3_min.attr, + &dev_attr_temp1_max.attr, + &dev_attr_temp2_max.attr, + &dev_attr_temp3_max.attr, + &dev_attr_vrm.attr, + &dev_attr_cpu0_vid.attr, + &dev_attr_alarms.attr, + &dev_attr_pwm1_auto_channels.attr, + &dev_attr_pwm2_auto_channels.attr, + &dev_attr_pwm3_auto_channels.attr, + &dev_attr_pwm1_auto_pwm_min.attr, + &dev_attr_pwm2_auto_pwm_min.attr, + &dev_attr_pwm3_auto_pwm_min.attr, + &dev_attr_pwm1_auto_pwm_minctl.attr, + &dev_attr_pwm2_auto_pwm_minctl.attr, + &dev_attr_pwm3_auto_pwm_minctl.attr, + &dev_attr_pwm1_auto_pwm_freq.attr, + &dev_attr_pwm2_auto_pwm_freq.attr, + &dev_attr_pwm3_auto_pwm_freq.attr, + &dev_attr_temp1_auto_temp_off.attr, + &dev_attr_temp2_auto_temp_off.attr, + &dev_attr_temp3_auto_temp_off.attr, + &dev_attr_temp1_auto_temp_min.attr, + &dev_attr_temp2_auto_temp_min.attr, + &dev_attr_temp3_auto_temp_min.attr, + &dev_attr_temp1_auto_temp_max.attr, + &dev_attr_temp2_auto_temp_max.attr, + &dev_attr_temp3_auto_temp_max.attr, + &dev_attr_temp1_auto_temp_crit.attr, + &dev_attr_temp2_auto_temp_crit.attr, + &dev_attr_temp3_auto_temp_crit.attr, + + NULL +}; + +static const struct attribute_group lm85_group = { + .attrs = lm85_attributes, +}; + +static struct attribute *lm85_attributes_opt[] = { + &dev_attr_in4_input.attr, + &dev_attr_in4_min.attr, + &dev_attr_in4_max.attr, + + NULL +}; + +static const struct attribute_group lm85_group_opt = { + .attrs = lm85_attributes_opt, +}; + static int lm85_detect(struct i2c_adapter *adapter, int address, int kind) { @@ -1163,87 +1246,33 @@ static int lm85_detect(struct i2c_adapte lm85_init_client(new_client); /* Register sysfs hooks */ - data->class_dev = hwmon_device_register(&new_client->dev); - if (IS_ERR(data->class_dev)) { - err = PTR_ERR(data->class_dev); + if ((err = sysfs_create_group(&new_client->dev.kobj, &lm85_group))) goto ERROR2; - } - - device_create_file(&new_client->dev, &dev_attr_fan1_input); - device_create_file(&new_client->dev, &dev_attr_fan2_input); - device_create_file(&new_client->dev, &dev_attr_fan3_input); - device_create_file(&new_client->dev, &dev_attr_fan4_input); - device_create_file(&new_client->dev, &dev_attr_fan1_min); - device_create_file(&new_client->dev, &dev_attr_fan2_min); - device_create_file(&new_client->dev, &dev_attr_fan3_min); - device_create_file(&new_client->dev, &dev_attr_fan4_min); - device_create_file(&new_client->dev, &dev_attr_pwm1); - device_create_file(&new_client->dev, &dev_attr_pwm2); - device_create_file(&new_client->dev, &dev_attr_pwm3); - device_create_file(&new_client->dev, &dev_attr_pwm1_enable); - device_create_file(&new_client->dev, &dev_attr_pwm2_enable); - device_create_file(&new_client->dev, &dev_attr_pwm3_enable); - 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_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_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_temp1_input); - device_create_file(&new_client->dev, &dev_attr_temp2_input); - device_create_file(&new_client->dev, &dev_attr_temp3_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_temp3_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_temp3_max); - device_create_file(&new_client->dev, &dev_attr_vrm); - device_create_file(&new_client->dev, &dev_attr_cpu0_vid); - device_create_file(&new_client->dev, &dev_attr_alarms); - device_create_file(&new_client->dev, &dev_attr_pwm1_auto_channels); - device_create_file(&new_client->dev, &dev_attr_pwm2_auto_channels); - device_create_file(&new_client->dev, &dev_attr_pwm3_auto_channels); - device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_min); - device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_min); - device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_min); - device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_minctl); - device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_minctl); - device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_minctl); - device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_freq); - device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_freq); - device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_freq); - device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_off); - device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_off); - device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_off); - device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_min); - device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_min); - device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_min); - device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_max); - device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_max); - device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_max); - device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_crit); - device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit); - device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit); /* The ADT7463 has an optional VRM 10 mode where pin 21 is used as a sixth digital VID input rather than an analog input. */ data->vid = lm85_read_value(new_client, LM85_REG_VID); - if (!(kind == adt7463 && (data->vid & 0x80))) { - device_create_file(&new_client->dev, &dev_attr_in4_input); - device_create_file(&new_client->dev, &dev_attr_in4_min); - device_create_file(&new_client->dev, &dev_attr_in4_max); + if (!(kind == adt7463 && (data->vid & 0x80))) + if ((err = device_create_file(&new_client->dev, + &dev_attr_in4_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in4_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in4_max))) + goto ERROR3; + + data->class_dev = hwmon_device_register(&new_client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto ERROR3; } return 0; /* Error out and cleanup code */ + ERROR3: + sysfs_remove_group(&new_client->dev.kobj, &lm85_group); + sysfs_remove_group(&new_client->dev.kobj, &lm85_group_opt); ERROR2: i2c_detach_client(new_client); ERROR1: @@ -1256,6 +1285,8 @@ static int lm85_detach_client(struct i2c { struct lm85_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &lm85_group); + sysfs_remove_group(&client->dev.kobj, &lm85_group_opt); i2c_detach_client(client); kfree(data); return 0; --- gregkh-2.6.orig/drivers/hwmon/lm87.c +++ gregkh-2.6/drivers/hwmon/lm87.c @@ -542,6 +542,78 @@ static int lm87_attach_adapter(struct i2 return i2c_probe(adapter, &addr_data, lm87_detect); } +static struct attribute *lm87_attributes[] = { + &dev_attr_in1_input.attr, + &dev_attr_in1_min.attr, + &dev_attr_in1_max.attr, + &dev_attr_in2_input.attr, + &dev_attr_in2_min.attr, + &dev_attr_in2_max.attr, + &dev_attr_in3_input.attr, + &dev_attr_in3_min.attr, + &dev_attr_in3_max.attr, + &dev_attr_in4_input.attr, + &dev_attr_in4_min.attr, + &dev_attr_in4_max.attr, + + &dev_attr_temp1_input.attr, + &dev_attr_temp1_max.attr, + &dev_attr_temp1_min.attr, + &dev_attr_temp1_crit.attr, + &dev_attr_temp2_input.attr, + &dev_attr_temp2_max.attr, + &dev_attr_temp2_min.attr, + &dev_attr_temp2_crit.attr, + + &dev_attr_alarms.attr, + &dev_attr_aout_output.attr, + + NULL +}; + +static const struct attribute_group lm87_group = { + .attrs = lm87_attributes, +}; + +static struct attribute *lm87_attributes_opt[] = { + &dev_attr_in6_input.attr, + &dev_attr_in6_min.attr, + &dev_attr_in6_max.attr, + + &dev_attr_fan1_input.attr, + &dev_attr_fan1_min.attr, + &dev_attr_fan1_div.attr, + + &dev_attr_in7_input.attr, + &dev_attr_in7_min.attr, + &dev_attr_in7_max.attr, + + &dev_attr_fan2_input.attr, + &dev_attr_fan2_min.attr, + &dev_attr_fan2_div.attr, + + &dev_attr_temp3_input.attr, + &dev_attr_temp3_max.attr, + &dev_attr_temp3_min.attr, + &dev_attr_temp3_crit.attr, + + &dev_attr_in0_input.attr, + &dev_attr_in0_min.attr, + &dev_attr_in0_max.attr, + &dev_attr_in5_input.attr, + &dev_attr_in5_min.attr, + &dev_attr_in5_max.attr, + + &dev_attr_cpu0_vid.attr, + &dev_attr_vrm.attr, + + NULL +}; + +static const struct attribute_group lm87_group_opt = { + .attrs = lm87_attributes_opt, +}; + /* * The following function does more than just detection. If detection * succeeds, it also registers the new chip. @@ -609,77 +681,90 @@ static int lm87_detect(struct i2c_adapte data->in_scale[7] = 1875; /* Register sysfs hooks */ - data->class_dev = hwmon_device_register(&new_client->dev); - if (IS_ERR(data->class_dev)) { - err = PTR_ERR(data->class_dev); + if ((err = sysfs_create_group(&new_client->dev.kobj, &lm87_group))) goto exit_detach; - } - - device_create_file(&new_client->dev, &dev_attr_in1_input); - device_create_file(&new_client->dev, &dev_attr_in1_min); - device_create_file(&new_client->dev, &dev_attr_in1_max); - device_create_file(&new_client->dev, &dev_attr_in2_input); - device_create_file(&new_client->dev, &dev_attr_in2_min); - device_create_file(&new_client->dev, &dev_attr_in2_max); - device_create_file(&new_client->dev, &dev_attr_in3_input); - device_create_file(&new_client->dev, &dev_attr_in3_min); - device_create_file(&new_client->dev, &dev_attr_in3_max); - device_create_file(&new_client->dev, &dev_attr_in4_input); - device_create_file(&new_client->dev, &dev_attr_in4_min); - device_create_file(&new_client->dev, &dev_attr_in4_max); if (data->channel & CHAN_NO_FAN(0)) { - device_create_file(&new_client->dev, &dev_attr_in6_input); - device_create_file(&new_client->dev, &dev_attr_in6_min); - device_create_file(&new_client->dev, &dev_attr_in6_max); + if ((err = device_create_file(&new_client->dev, + &dev_attr_in6_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in6_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in6_max))) + goto exit_remove; } else { - device_create_file(&new_client->dev, &dev_attr_fan1_input); - device_create_file(&new_client->dev, &dev_attr_fan1_min); - device_create_file(&new_client->dev, &dev_attr_fan1_div); + if ((err = device_create_file(&new_client->dev, + &dev_attr_fan1_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_fan1_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_fan1_div))) + goto exit_remove; } + if (data->channel & CHAN_NO_FAN(1)) { - device_create_file(&new_client->dev, &dev_attr_in7_input); - device_create_file(&new_client->dev, &dev_attr_in7_min); - device_create_file(&new_client->dev, &dev_attr_in7_max); + if ((err = device_create_file(&new_client->dev, + &dev_attr_in7_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in7_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in7_max))) + goto exit_remove; } else { - device_create_file(&new_client->dev, &dev_attr_fan2_input); - device_create_file(&new_client->dev, &dev_attr_fan2_min); - device_create_file(&new_client->dev, &dev_attr_fan2_div); + if ((err = device_create_file(&new_client->dev, + &dev_attr_fan2_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_fan2_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_fan2_div))) + goto exit_remove; } - device_create_file(&new_client->dev, &dev_attr_temp1_input); - 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_crit); - device_create_file(&new_client->dev, &dev_attr_temp2_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_crit); - if (data->channel & CHAN_TEMP3) { - device_create_file(&new_client->dev, &dev_attr_temp3_input); - device_create_file(&new_client->dev, &dev_attr_temp3_max); - device_create_file(&new_client->dev, &dev_attr_temp3_min); - device_create_file(&new_client->dev, &dev_attr_temp3_crit); + if ((err = device_create_file(&new_client->dev, + &dev_attr_temp3_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_temp3_max)) + || (err = device_create_file(&new_client->dev, + &dev_attr_temp3_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_temp3_crit))) + goto exit_remove; } else { - device_create_file(&new_client->dev, &dev_attr_in0_input); - device_create_file(&new_client->dev, &dev_attr_in0_min); - device_create_file(&new_client->dev, &dev_attr_in0_max); - device_create_file(&new_client->dev, &dev_attr_in5_input); - device_create_file(&new_client->dev, &dev_attr_in5_min); - device_create_file(&new_client->dev, &dev_attr_in5_max); + if ((err = device_create_file(&new_client->dev, + &dev_attr_in0_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in0_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in0_max)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in5_input)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in5_min)) + || (err = device_create_file(&new_client->dev, + &dev_attr_in5_max))) + goto exit_remove; } if (!(data->channel & CHAN_NO_VID)) { - device_create_file(&new_client->dev, &dev_attr_cpu0_vid); - device_create_file(&new_client->dev, &dev_attr_vrm); + if ((err = device_create_file(&new_client->dev, + &dev_attr_cpu0_vid)) + || (err = device_create_file(&new_client->dev, + &dev_attr_vrm))) + goto exit_remove; } - device_create_file(&new_client->dev, &dev_attr_alarms); - device_create_file(&new_client->dev, &dev_attr_aout_output); + 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; +exit_remove: + sysfs_remove_group(&new_client->dev.kobj, &lm87_group); + sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt); exit_detach: i2c_detach_client(new_client); exit_free: @@ -732,6 +817,8 @@ static int lm87_detach_client(struct i2c int err; hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &lm87_group); + sysfs_remove_group(&client->dev.kobj, &lm87_group_opt); if ((err = i2c_detach_client(client))) return err; --- gregkh-2.6.orig/drivers/hwmon/lm92.c +++ gregkh-2.6/drivers/hwmon/lm92.c @@ -288,6 +288,23 @@ static int max6635_check(struct i2c_clie return 1; } +static struct attribute *lm92_attributes[] = { + &dev_attr_temp1_input.attr, + &dev_attr_temp1_crit.attr, + &dev_attr_temp1_crit_hyst.attr, + &dev_attr_temp1_min.attr, + &dev_attr_temp1_min_hyst.attr, + &dev_attr_temp1_max.attr, + &dev_attr_temp1_max_hyst.attr, + &dev_attr_alarms.attr, + + NULL +}; + +static const struct attribute_group lm92_group = { + .attrs = lm92_attributes, +}; + /* The following function does more than just detection. If detection succeeds, it also registers the new chip. */ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind) @@ -359,23 +376,19 @@ static int lm92_detect(struct i2c_adapte lm92_init_client(new_client); /* Register sysfs hooks */ + if ((err = sysfs_create_group(&new_client->dev.kobj, &lm92_group))) + goto exit_detach; + data->class_dev = hwmon_device_register(&new_client->dev); if (IS_ERR(data->class_dev)) { err = PTR_ERR(data->class_dev); - goto exit_detach; + goto exit_remove; } - device_create_file(&new_client->dev, &dev_attr_temp1_input); - device_create_file(&new_client->dev, &dev_attr_temp1_crit); - device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); - device_create_file(&new_client->dev, &dev_attr_temp1_min); - device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst); - device_create_file(&new_client->dev, &dev_attr_temp1_max); - device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); - device_create_file(&new_client->dev, &dev_attr_alarms); - return 0; +exit_remove: + sysfs_remove_group(&new_client->dev.kobj, &lm92_group); exit_detach: i2c_detach_client(new_client); exit_free: @@ -397,6 +410,7 @@ static int lm92_detach_client(struct i2c int err; hwmon_device_unregister(data->class_dev); + sysfs_remove_group(&client->dev.kobj, &lm92_group); if ((err = i2c_detach_client(client))) return err; Patches currently in gregkh-2.6 which might be from khali at linux-fr.org are i2c/hwmon-w83627ehf-add-pwm-support.patch i2c/hwmon-w83627ehf-documentation.patch i2c/hwmon-k8temp-documentation.patch i2c/hwmon-abituguru-suspend-resume.patch i2c/hwmon-individual-alarm-files-1.patch i2c/hwmon-kconfig-update.patch i2c/hwmon-it87-disabled-fans.patch i2c/hwmon-remove-yuan-mu-address.patch i2c/hwmon-unchecked-return-status-fixes-1.patch i2c/hwmon-unchecked-return-status-fixes-2.patch i2c/hwmon-unchecked-return-status-fixes-3.patch i2c/hwmon-unchecked-return-status-fixes-4.patch i2c/hwmon-unchecked-return-status-fixes-5.patch i2c/hwmon-unchecked-return-status-fixes-6.patch i2c/hwmon-unchecked-return-status-fixes-pc87360-1.patch i2c/hwmon-unchecked-return-status-fixes-pc87360-2.patch i2c/hwmon-unchecked-return-status-fixes-pc87360-3.patch i2c/hwmon-unchecked-return-status-fixes-smsc.patch i2c/hwmon-unchecked-return-status-fixes-vt8231.patch i2c/hwmon-atxp1-signed-unsigned-char-bug.patch i2c/hwmon-hdaps-handle-errors-from-input-register-device.patch i2c/hwmon-it87-copyright-update.patch i2c/hwmon-it87-div-to-reg-overflow.patch i2c/hwmon-it87-in8-no-limits.patch i2c/hwmon-it87-it8716f-support.patch i2c/hwmon-it87-it8718f-support.patch i2c/hwmon-it87-sane-limit-defaults.patch i2c/hwmon-it87-set-fan-div.patch i2c/hwmon-k8temp-autoload.patch i2c/hwmon-k8temp-new-driver.patch i2c/hwmon-smsc47m1-fix-dev-message.patch i2c/hwmon-unchecked-return-status-fixes-w83627ehf.patch i2c/hwmon-unchecked-return-status-fixes-w83781d.patch i2c/hwmon-unchecked-return-status-fixes-w83792d.patch i2c/hwmon-unchecked-return-status-fixes-w83l785ts.patch i2c/hwmon-vt1211-add-module-parameters-description.patch i2c/hwmon-vt1211-documentation.patch i2c/hwmon-vt1211-new-driver.patch i2c/hwmon-w83791d-doc-update.patch driver-class/i2c-dev-device.patch driver-class/i2c-dev-device.old.patch