diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 09:58:04 -0700 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-21 21:48:39 -0700 |
commit | 6ecffe16911dc79b079b6fb4491fd157c62d4371 (patch) | |
tree | 56a3e4e8f821416da7ef4d208dc461c3f7de4a0b /drivers/hwmon | |
parent | e20b4b38cdf1622d1577ae5e402ded2bd63bf616 (diff) |
hwmon: (emc6w201) 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')
-rw-r--r-- | drivers/hwmon/emc6w201.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/hwmon/emc6w201.c b/drivers/hwmon/emc6w201.c index 840f5112e60..ada12a98a97 100644 --- a/drivers/hwmon/emc6w201.c +++ b/drivers/hwmon/emc6w201.c @@ -492,11 +492,10 @@ static int emc6w201_probe(struct i2c_client *client, struct emc6w201_data *data; int err; - data = kzalloc(sizeof(struct emc6w201_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto exit; - } + data = devm_kzalloc(&client->dev, sizeof(struct emc6w201_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; i2c_set_clientdata(client, data); mutex_init(&data->update_lock); @@ -504,7 +503,7 @@ static int emc6w201_probe(struct i2c_client *client, /* Create sysfs attribute */ err = sysfs_create_group(&client->dev.kobj, &emc6w201_group); if (err) - goto exit_free; + return err; /* Expose as a hwmon device */ data->hwmon_dev = hwmon_device_register(&client->dev); @@ -517,9 +516,6 @@ static int emc6w201_probe(struct i2c_client *client, exit_remove: sysfs_remove_group(&client->dev.kobj, &emc6w201_group); - exit_free: - kfree(data); - exit: return err; } @@ -529,7 +525,6 @@ static int emc6w201_remove(struct i2c_client *client) hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &emc6w201_group); - kfree(data); return 0; } |