summaryrefslogtreecommitdiff
path: root/drivers/power/ds2781_battery.c
diff options
context:
space:
mode:
authorDevendra Naga <develkernel412222@gmail.com>2012-07-30 16:29:33 +0545
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-08-22 19:47:14 -0700
commitdeacc4fe57794f80ad4449c7cea611921c2d0420 (patch)
tree69de0e89f91951d9bcdec779ea645fbb1b4899f2 /drivers/power/ds2781_battery.c
parentbc6e51d8891629a9d117dc75a8a2eb9a411a3510 (diff)
downloadlwn-deacc4fe57794f80ad4449c7cea611921c2d0420.tar.gz
lwn-deacc4fe57794f80ad4449c7cea611921c2d0420.zip
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/ds2781_battery.c')
-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)
int ret = 0;
struct ds2781_device_info *dev_info;
- dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
- if (!dev_info) {
- ret = -ENOMEM;
- goto fail;
- }
+ dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL);
+ if (!dev_info)
+ return -ENOMEM;
platform_set_drvdata(pdev, dev_info);
@@ -774,7 +772,7 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
ret = power_supply_register(&pdev->dev, &dev_info->bat);
if (ret) {
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);
@@ -808,8 +806,6 @@ fail_remove_group:
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
fail_unregister:
power_supply_unregister(&dev_info->bat);
-fail_free_info:
- kfree(dev_info);
fail:
return ret;
}
@@ -823,7 +819,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
power_supply_unregister(&dev_info->bat);
- kfree(dev_info);
return 0;
}