hwmon: (lm87) 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
747e5d62ac
commit
5ff512b458
|
@ -898,11 +898,9 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||
struct lm87_data *data;
|
||||
int err;
|
||||
|
||||
data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct lm87_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
|
@ -923,7 +921,7 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||
/* Register sysfs hooks */
|
||||
err = sysfs_create_group(&client->dev.kobj, &lm87_group);
|
||||
if (err)
|
||||
goto exit_free;
|
||||
goto exit_stop;
|
||||
|
||||
if (data->channel & CHAN_NO_FAN(0)) {
|
||||
err = sysfs_create_group(&client->dev.kobj, &lm87_group_in6);
|
||||
|
@ -972,10 +970,8 @@ static int lm87_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||
|
||||
exit_remove:
|
||||
lm87_remove_files(client);
|
||||
exit_free:
|
||||
exit_stop:
|
||||
lm87_write_value(client, LM87_REG_CONFIG, data->config);
|
||||
kfree(data);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -987,7 +983,6 @@ static int lm87_remove(struct i2c_client *client)
|
|||
lm87_remove_files(client);
|
||||
|
||||
lm87_write_value(client, LM87_REG_CONFIG, data->config);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue