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>
This commit is contained in:
parent
b92ff855b9
commit
2cb12122b8
|
@ -760,7 +760,7 @@ static int ds2780_battery_probe(struct platform_device *pdev)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct ds2780_device_info *dev_info;
|
struct ds2780_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;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -779,7 +779,7 @@ static int ds2780_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, &ds2780_attr_group);
|
ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);
|
||||||
|
@ -813,8 +813,6 @@ fail_remove_group:
|
||||||
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);
|
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_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;
|
||||||
}
|
}
|
||||||
|
@ -828,7 +826,6 @@ static int ds2780_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue