summaryrefslogtreecommitdiff
path: root/drivers/hwmon/lm77.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-16 18:24:02 -0700
committerGuenter Roeck <linux@roeck-us.net>2012-07-21 21:48:40 -0700
commit52714c04df4b12ca308a1d792d50681df43365c2 (patch)
treee40f230a13530514c59e4d7d06abff9c55e005a6 /drivers/hwmon/lm77.c
parentefd2d117aeb5f01cc9c90e56fff29d4a5f535580 (diff)
hwmon: (lm77) 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>
Diffstat (limited to 'drivers/hwmon/lm77.c')
-rw-r--r--drivers/hwmon/lm77.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index 3ccc23a0c7f5..f82acf67acf5 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -343,11 +343,9 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id)
struct lm77_data *data;
int err;
- data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL);
- if (!data) {
- err = -ENOMEM;
- goto exit;
- }
+ data = devm_kzalloc(dev, sizeof(struct lm77_data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
i2c_set_clientdata(client, data);
data->valid = 0;
@@ -359,7 +357,7 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* Register sysfs hooks */
err = sysfs_create_group(&dev->kobj, &lm77_group);
if (err)
- goto exit_free;
+ return err;
data->hwmon_dev = hwmon_device_register(dev);
if (IS_ERR(data->hwmon_dev)) {
@@ -371,9 +369,6 @@ static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id)
exit_remove:
sysfs_remove_group(&dev->kobj, &lm77_group);
-exit_free:
- kfree(data);
-exit:
return err;
}
@@ -382,7 +377,6 @@ static int lm77_remove(struct i2c_client *client)
struct lm77_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &lm77_group);
- kfree(data);
return 0;
}