hwmon: (adm1031) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
3421e212e6
commit
dc2fd66327
|
@ -954,11 +954,10 @@ static int adm1031_probe(struct i2c_client *client,
|
||||||
struct adm1031_data *data;
|
struct adm1031_data *data;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL);
|
data = devm_kzalloc(&client->dev, sizeof(struct adm1031_data),
|
||||||
if (!data) {
|
GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
if (!data)
|
||||||
goto exit;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
i2c_set_clientdata(client, data);
|
i2c_set_clientdata(client, data);
|
||||||
data->chip_type = id->driver_data;
|
data->chip_type = id->driver_data;
|
||||||
|
@ -975,7 +974,7 @@ static int adm1031_probe(struct i2c_client *client,
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
err = sysfs_create_group(&client->dev.kobj, &adm1031_group);
|
err = sysfs_create_group(&client->dev.kobj, &adm1031_group);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_free;
|
return err;
|
||||||
|
|
||||||
if (data->chip_type == adm1031) {
|
if (data->chip_type == adm1031) {
|
||||||
err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt);
|
err = sysfs_create_group(&client->dev.kobj, &adm1031_group_opt);
|
||||||
|
@ -994,9 +993,6 @@ static int adm1031_probe(struct i2c_client *client,
|
||||||
exit_remove:
|
exit_remove:
|
||||||
sysfs_remove_group(&client->dev.kobj, &adm1031_group);
|
sysfs_remove_group(&client->dev.kobj, &adm1031_group);
|
||||||
sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
|
sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
|
||||||
exit_free:
|
|
||||||
kfree(data);
|
|
||||||
exit:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,7 +1003,6 @@ static int adm1031_remove(struct i2c_client *client)
|
||||||
hwmon_device_unregister(data->hwmon_dev);
|
hwmon_device_unregister(data->hwmon_dev);
|
||||||
sysfs_remove_group(&client->dev.kobj, &adm1031_group);
|
sysfs_remove_group(&client->dev.kobj, &adm1031_group);
|
||||||
sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
|
sysfs_remove_group(&client->dev.kobj, &adm1031_group_opt);
|
||||||
kfree(data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue