aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorDevendra Naga <develkernel412222@gmail.com>2012-07-30 06:44:33 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-08-22 22:47:14 -0400
commitdeacc4fe57794f80ad4449c7cea611921c2d0420 (patch)
tree69de0e89f91951d9bcdec779ea645fbb1b4899f2 /drivers/power
parentbc6e51d8891629a9d117dc75a8a2eb9a411a3510 (diff)
ds2781_battery: Replace call to kzalloc with devm_kzalloc
With devm_kzalloc there is no need of freeing at the errorpath and also at unregister it. Signed-off-by: Devendra Naga <develkernel412222@gmail.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ds2781_battery.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/power/ds2781_battery.c b/drivers/power/ds2781_battery.c
index 88e304aea2dc..22b3c8c93552 100644
--- a/drivers/power/ds2781_battery.c
+++ b/drivers/power/ds2781_battery.c
@@ -755,11 +755,9 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
755 int ret = 0; 755 int ret = 0;
756 struct ds2781_device_info *dev_info; 756 struct ds2781_device_info *dev_info;
757 757
758 dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); 758 dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL);
759 if (!dev_info) { 759 if (!dev_info)
760 ret = -ENOMEM; 760 return -ENOMEM;
761 goto fail;
762 }
763 761
764 platform_set_drvdata(pdev, dev_info); 762 platform_set_drvdata(pdev, dev_info);
765 763
@@ -774,7 +772,7 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
774 ret = power_supply_register(&pdev->dev, &dev_info->bat); 772 ret = power_supply_register(&pdev->dev, &dev_info->bat);
775 if (ret) { 773 if (ret) {
776 dev_err(dev_info->dev, "failed to register battery\n"); 774 dev_err(dev_info->dev, "failed to register battery\n");
777 goto fail_free_info; 775 goto fail;
778 } 776 }
779 777
780 ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); 778 ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
@@ -808,8 +806,6 @@ fail_remove_group:
808 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); 806 sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
809fail_unregister: 807fail_unregister:
810 power_supply_unregister(&dev_info->bat); 808 power_supply_unregister(&dev_info->bat);
811fail_free_info:
812 kfree(dev_info);
813fail: 809fail:
814 return ret; 810 return ret;
815} 811}
@@ -823,7 +819,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
823 819
824 power_supply_unregister(&dev_info->bat); 820 power_supply_unregister(&dev_info->bat);
825 821
826 kfree(dev_info);
827 return 0; 822 return 0;
828} 823}
829 824