Commit deacc4fe authored by Devendra Naga's avatar Devendra Naga Committed by Anton Vorontsov

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: default avatarDevendra Naga <develkernel412222@gmail.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent bc6e51d8
...@@ -755,11 +755,9 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev) ...@@ -755,11 +755,9 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
struct ds2781_device_info *dev_info; struct ds2781_device_info *dev_info;
dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL); dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL);
if (!dev_info) { if (!dev_info)
ret = -ENOMEM; return -ENOMEM;
goto fail;
}
platform_set_drvdata(pdev, dev_info); platform_set_drvdata(pdev, dev_info);
...@@ -774,7 +772,7 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev) ...@@ -774,7 +772,7 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
ret = power_supply_register(&pdev->dev, &dev_info->bat); ret = power_supply_register(&pdev->dev, &dev_info->bat);
if (ret) { if (ret) {
dev_err(dev_info->dev, "failed to register battery\n"); dev_err(dev_info->dev, "failed to register battery\n");
goto fail_free_info; goto fail;
} }
ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
...@@ -808,8 +806,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev) ...@@ -808,8 +806,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group); sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
fail_unregister: fail_unregister:
power_supply_unregister(&dev_info->bat); power_supply_unregister(&dev_info->bat);
fail_free_info:
kfree(dev_info);
fail: fail:
return ret; return ret;
} }
...@@ -823,7 +819,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev) ...@@ -823,7 +819,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
power_supply_unregister(&dev_info->bat); power_supply_unregister(&dev_info->bat);
kfree(dev_info);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment