Skip to content

Commit

Permalink
hwmon: (emc6w201) Convert to use devm_ functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck committed Jul 22, 2012
1 parent e20b4b3 commit 6ecffe1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions drivers/hwmon/emc6w201.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,19 +492,18 @@ 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);

/* 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);
Expand All @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 6ecffe1

Please sign in to comment.