Move sysfs files removal to a separate function. The code is common to the device probing error path and the standard device removal path. As it will grow with future driver development, this avoids code duplication. Signed-off-by: Jean Delvare <khali@xxxxxxxxxxxx> Cc: Hans de Goede <hdegoede@xxxxxxxxxx> Cc: Jordan Crouse <jordan@xxxxxxxxxxxxxxxxx> Cc: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- drivers/hwmon/adt7475.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) --- linux-2.6.32-rc8.orig/drivers/hwmon/adt7475.c 2009-12-02 13:27:55.000000000 +0100 +++ linux-2.6.32-rc8/drivers/hwmon/adt7475.c 2009-12-02 13:34:48.000000000 +0100 @@ -1109,6 +1109,14 @@ static int adt7475_detect(struct i2c_cli return 0; } +static void adt7475_remove_files(struct i2c_client *client, + struct adt7475_data *data) +{ + sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); + if (data->has_voltage & 0x39) + sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group); +} + static int adt7475_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1156,9 +1164,7 @@ static int adt7475_probe(struct i2c_clie return 0; eremove: - sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); - if (data->has_voltage & 0x39) - sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group); + adt7475_remove_files(client, data); efree: kfree(data); return ret; @@ -1169,9 +1175,7 @@ static int adt7475_remove(struct i2c_cli struct adt7475_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group); - if (data->has_voltage & 0x39) - sysfs_remove_group(&client->dev.kobj, &adt7490_attr_group); + adt7475_remove_files(client, data); kfree(data); return 0; -- Jean Delvare _______________________________________________ lm-sensors mailing list lm-sensors@xxxxxxxxxxxxxx http://lists.lm-sensors.org/mailman/listinfo/lm-sensors