Skip to content

Commit

Permalink
hwmon: (lm85) Use function to remove sysfs attribute files
Browse files Browse the repository at this point in the history
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
  • Loading branch information
Guenter Roeck committed Mar 15, 2011
1 parent de24880 commit bc6db2b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions drivers/hwmon/lm85.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,15 @@ static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
return 0;
}

static void lm85_remove_files(struct i2c_client *client, struct lm85_data *data)
{
sysfs_remove_group(&client->dev.kobj, &lm85_group);
if (!data->has_vid5)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
if (data->type == emc6d100)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
}

static int lm85_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
Expand Down Expand Up @@ -1349,10 +1358,7 @@ static int lm85_probe(struct i2c_client *client,

/* Error out and cleanup code */
err_remove_files:
sysfs_remove_group(&client->dev.kobj, &lm85_group);
sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
if (data->type == emc6d100)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
lm85_remove_files(client, data);
err_kfree:
kfree(data);
return err;
Expand All @@ -1362,10 +1368,7 @@ static int lm85_remove(struct i2c_client *client)
{
struct lm85_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm85_group);
sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
if (data->type == emc6d100)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
lm85_remove_files(client, data);
kfree(data);
return 0;
}
Expand Down

0 comments on commit bc6db2b

Please sign in to comment.