diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-03-11 02:33:05 -0400 |
---|---|---|
committer | Anton Vorontsov <anton@enomsg.org> | 2013-04-01 02:25:45 -0400 |
commit | 2cb12122b8173e535619a833d5efc65cef718239 (patch) | |
tree | 1de7c8c5dca08656914f000f4a1ad177f498538d /drivers/power/ds2780_battery.c | |
parent | b92ff855b97795d8be3115c0aff04f6efb5a53aa (diff) |
ds2780_battery: Use devm_kzalloc()
Use devm_kzalloc() to make cleanup paths more simple.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power/ds2780_battery.c')
-rw-r--r-- | drivers/power/ds2780_battery.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c index 8b6c4539e7f4..9f418fa879e5 100644 --- a/drivers/power/ds2780_battery.c +++ b/drivers/power/ds2780_battery.c | |||
@@ -760,7 +760,7 @@ static int ds2780_battery_probe(struct platform_device *pdev) | |||
760 | int ret = 0; | 760 | int ret = 0; |
761 | struct ds2780_device_info *dev_info; | 761 | struct ds2780_device_info *dev_info; |
762 | 762 | ||
763 | dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); | 763 | dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL); |
764 | if (!dev_info) { | 764 | if (!dev_info) { |
765 | ret = -ENOMEM; | 765 | ret = -ENOMEM; |
766 | goto fail; | 766 | goto fail; |
@@ -779,7 +779,7 @@ static int ds2780_battery_probe(struct platform_device *pdev) | |||
779 | ret = power_supply_register(&pdev->dev, &dev_info->bat); | 779 | ret = power_supply_register(&pdev->dev, &dev_info->bat); |
780 | if (ret) { | 780 | if (ret) { |
781 | dev_err(dev_info->dev, "failed to register battery\n"); | 781 | dev_err(dev_info->dev, "failed to register battery\n"); |
782 | goto fail_free_info; | 782 | goto fail; |
783 | } | 783 | } |
784 | 784 | ||
785 | ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2780_attr_group); | 785 | ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2780_attr_group); |
@@ -813,8 +813,6 @@ fail_remove_group: | |||
813 | sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group); | 813 | sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group); |
814 | fail_unregister: | 814 | fail_unregister: |
815 | power_supply_unregister(&dev_info->bat); | 815 | power_supply_unregister(&dev_info->bat); |
816 | fail_free_info: | ||
817 | kfree(dev_info); | ||
818 | fail: | 816 | fail: |
819 | return ret; | 817 | return ret; |
820 | } | 818 | } |
@@ -828,7 +826,6 @@ static int ds2780_battery_remove(struct platform_device *pdev) | |||
828 | 826 | ||
829 | power_supply_unregister(&dev_info->bat); | 827 | power_supply_unregister(&dev_info->bat); |
830 | 828 | ||
831 | kfree(dev_info); | ||
832 | return 0; | 829 | return 0; |
833 | } | 830 | } |
834 | 831 | ||