ds2760_battery: Use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Mon, 11 Mar 2013 06:32:44 +0000 (15:32 +0900)
committerAnton Vorontsov <anton@enomsg.org>
Mon, 1 Apr 2013 06:25:47 +0000 (23:25 -0700)
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>
drivers/power/ds2760_battery.c

index 704e652072be08acb238f8a3b8965beb90cdf10b..85b4e6eca0b1984cc39ea0a3e0d6fbd5614ab543 100644 (file)
@@ -512,7 +512,7 @@ static int ds2760_battery_probe(struct platform_device *pdev)
        int retval = 0;
        struct ds2760_device_info *di;
 
-       di = kzalloc(sizeof(*di), GFP_KERNEL);
+       di = devm_kzalloc(&pdev->dev, sizeof(*di), GFP_KERNEL);
        if (!di) {
                retval = -ENOMEM;
                goto di_alloc_failed;
@@ -576,7 +576,6 @@ static int ds2760_battery_probe(struct platform_device *pdev)
 workqueue_failed:
        power_supply_unregister(&di->bat);
 batt_failed:
-       kfree(di);
 di_alloc_failed:
 success:
        return retval;
@@ -590,7 +589,6 @@ static int ds2760_battery_remove(struct platform_device *pdev)
        cancel_delayed_work_sync(&di->set_charged_work);
        destroy_workqueue(di->monitor_wqueue);
        power_supply_unregister(&di->bat);
-       kfree(di);
 
        return 0;
 }