]> git.karo-electronics.de Git - linux-beck.git/commitdiff
da9030_battery: Use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Mon, 11 Mar 2013 06:31:59 +0000 (15:31 +0900)
committerAnton Vorontsov <anton@enomsg.org>
Mon, 1 Apr 2013 06:25:51 +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/da9030_battery.c

index e8c5a391a4987b650f4699b516d6371456b06bda..ae6c41835ee6043eef81481b07db6ac467057abc 100644 (file)
@@ -505,7 +505,7 @@ static int da9030_battery_probe(struct platform_device *pdev)
            pdata->charge_millivolt > 4350)
                return -EINVAL;
 
-       charger = kzalloc(sizeof(*charger), GFP_KERNEL);
+       charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
        if (charger == NULL)
                return -ENOMEM;
 
@@ -557,8 +557,6 @@ err_notifier:
        cancel_delayed_work(&charger->work);
 
 err_charger_init:
-       kfree(charger);
-
        return ret;
 }
 
@@ -575,8 +573,6 @@ static int da9030_battery_remove(struct platform_device *dev)
        da9030_set_charge(charger, 0);
        power_supply_unregister(&charger->psy);
 
-       kfree(charger);
-
        return 0;
 }