diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:00 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:39 -0400 |
commit | e5ebb772c697540f42a4b74f3d14fae6ecd4de24 (patch) | |
tree | 36db264ab9f69613e264558b5c48b7b85ced3111 /drivers/hwmon/adm9240.c | |
parent | dc2fd6632788bcbe6243a50c6c819fc11b5da76b (diff) |
hwmon: (adm9240) 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/adm9240.c')
-rw-r--r-- | drivers/hwmon/adm9240.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index c3c2865a8967..5a78d102a0fa 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -650,11 +650,9 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
650 | struct adm9240_data *data; | 650 | struct adm9240_data *data; |
651 | int err; | 651 | int err; |
652 | 652 | ||
653 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 653 | data = devm_kzalloc(&new_client->dev, sizeof(*data), GFP_KERNEL); |
654 | if (!data) { | 654 | if (!data) |
655 | err = -ENOMEM; | 655 | return -ENOMEM; |
656 | goto exit; | ||
657 | } | ||
658 | 656 | ||
659 | i2c_set_clientdata(new_client, data); | 657 | i2c_set_clientdata(new_client, data); |
660 | mutex_init(&data->update_lock); | 658 | mutex_init(&data->update_lock); |
@@ -664,7 +662,7 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
664 | /* populate sysfs filesystem */ | 662 | /* populate sysfs filesystem */ |
665 | err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group); | 663 | err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group); |
666 | if (err) | 664 | if (err) |
667 | goto exit_free; | 665 | return err; |
668 | 666 | ||
669 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 667 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
670 | if (IS_ERR(data->hwmon_dev)) { | 668 | if (IS_ERR(data->hwmon_dev)) { |
@@ -676,9 +674,6 @@ static int adm9240_probe(struct i2c_client *new_client, | |||
676 | 674 | ||
677 | exit_remove: | 675 | exit_remove: |
678 | sysfs_remove_group(&new_client->dev.kobj, &adm9240_group); | 676 | sysfs_remove_group(&new_client->dev.kobj, &adm9240_group); |
679 | exit_free: | ||
680 | kfree(data); | ||
681 | exit: | ||
682 | return err; | 677 | return err; |
683 | } | 678 | } |
684 | 679 | ||
@@ -689,7 +684,6 @@ static int adm9240_remove(struct i2c_client *client) | |||
689 | hwmon_device_unregister(data->hwmon_dev); | 684 | hwmon_device_unregister(data->hwmon_dev); |
690 | sysfs_remove_group(&client->dev.kobj, &adm9240_group); | 685 | sysfs_remove_group(&client->dev.kobj, &adm9240_group); |
691 | 686 | ||
692 | kfree(data); | ||
693 | return 0; | 687 | return 0; |
694 | } | 688 | } |
695 | 689 | ||