hwmon: (lm80) 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:
Guenter Roeck 2012-06-02 09:58:09 -07:00
parent 52714c04df
commit c38b2820cb
1 changed files with 4 additions and 10 deletions

View File

@ -543,11 +543,9 @@ static int lm80_probe(struct i2c_client *client,
struct lm80_data *data; struct lm80_data *data;
int err; int err;
data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(struct lm80_data), GFP_KERNEL);
if (!data) { if (!data)
err = -ENOMEM; return -ENOMEM;
goto exit;
}
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
@ -562,7 +560,7 @@ static int lm80_probe(struct i2c_client *client,
/* Register sysfs hooks */ /* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &lm80_group); err = sysfs_create_group(&client->dev.kobj, &lm80_group);
if (err) if (err)
goto error_free; return err;
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
@ -574,9 +572,6 @@ static int lm80_probe(struct i2c_client *client,
error_remove: error_remove:
sysfs_remove_group(&client->dev.kobj, &lm80_group); sysfs_remove_group(&client->dev.kobj, &lm80_group);
error_free:
kfree(data);
exit:
return err; return err;
} }
@ -587,7 +582,6 @@ static int lm80_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm80_group); sysfs_remove_group(&client->dev.kobj, &lm80_group);
kfree(data);
return 0; return 0;
} }