Commit bc6db2b5 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (lm85) Use function to remove sysfs attribute files

Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
Acked-by: default avatarJean Delvare <khali@linux-fr.org>
parent de248805
...@@ -1281,6 +1281,15 @@ static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info) ...@@ -1281,6 +1281,15 @@ static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
return 0; 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, static int lm85_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -1349,10 +1358,7 @@ static int lm85_probe(struct i2c_client *client, ...@@ -1349,10 +1358,7 @@ static int lm85_probe(struct i2c_client *client,
/* Error out and cleanup code */ /* Error out and cleanup code */
err_remove_files: err_remove_files:
sysfs_remove_group(&client->dev.kobj, &lm85_group); lm85_remove_files(client, data);
sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
if (data->type == emc6d100)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
err_kfree: err_kfree:
kfree(data); kfree(data);
return err; return err;
...@@ -1362,10 +1368,7 @@ static int lm85_remove(struct i2c_client *client) ...@@ -1362,10 +1368,7 @@ static int lm85_remove(struct i2c_client *client)
{ {
struct lm85_data *data = i2c_get_clientdata(client); struct lm85_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm85_group); lm85_remove_files(client, data);
sysfs_remove_group(&client->dev.kobj, &lm85_group_in4);
if (data->type == emc6d100)
sysfs_remove_group(&client->dev.kobj, &lm85_group_in567);
kfree(data); kfree(data);
return 0; return 0;
} }
......
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