summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max6639.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 09:58:13 -0700
committerGuenter Roeck <linux@roeck-us.net>2012-07-21 21:48:38 -0700
commitb07405fbc38f2e7f2eef2f38fa724a7510ae14aa (patch)
tree4704468230046344824f81a189b7cbf354f93ff2 /drivers/hwmon/max6639.c
parent94cd52027aa52780e56e11fd08703d955f0ff91e (diff)
downloadlinux-b07405fbc38f2e7f2eef2f38fa724a7510ae14aa.tar.gz
linux-b07405fbc38f2e7f2eef2f38fa724a7510ae14aa.tar.bz2
linux-b07405fbc38f2e7f2eef2f38fa724a7510ae14aa.zip
hwmon: (max6639) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Roland Stigge <stigge@antcom.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Roland Stigge <stigge@antcom.de>
Diffstat (limited to 'drivers/hwmon/max6639.c')
-rw-r--r--drivers/hwmon/max6639.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c
index de8f7adaccbd..6e60036abfa7 100644
--- a/drivers/hwmon/max6639.c
+++ b/drivers/hwmon/max6639.c
@@ -548,11 +548,10 @@ static int max6639_probe(struct i2c_client *client,
struct max6639_data *data;
int err;
- data = kzalloc(sizeof(struct max6639_data), GFP_KERNEL);
- if (!data) {
- err = -ENOMEM;
- goto exit;
- }
+ data = devm_kzalloc(&client->dev, sizeof(struct max6639_data),
+ GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);
@@ -560,12 +559,12 @@ static int max6639_probe(struct i2c_client *client,
/* Initialize the max6639 chip */
err = max6639_init_client(client);
if (err < 0)
- goto error_free;
+ return err;
/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &max6639_group);
if (err)
- goto error_free;
+ return err;
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
@@ -579,9 +578,6 @@ static int max6639_probe(struct i2c_client *client,
error_remove:
sysfs_remove_group(&client->dev.kobj, &max6639_group);
-error_free:
- kfree(data);
-exit:
return err;
}
@@ -592,7 +588,6 @@ static int max6639_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &max6639_group);
- kfree(data);
return 0;
}