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

index 08193feb3b088bc7ae7d43134e6a12e7e2f75da9..f8f4c0f7c17da6085914b7868aa396b41073714c 100644 (file)
@@ -594,7 +594,8 @@ static s32 da9052_bat_probe(struct platform_device *pdev)
        int ret;
        int i;
 
-       bat = kzalloc(sizeof(struct da9052_battery), GFP_KERNEL);
+       bat = devm_kzalloc(&pdev->dev, sizeof(struct da9052_battery),
+                               GFP_KERNEL);
        if (!bat)
                return -ENOMEM;
 
@@ -635,7 +636,6 @@ err:
        while (--i >= 0)
                da9052_free_irq(bat->da9052, da9052_bat_irq_bits[i], bat);
 
-       kfree(bat);
        return ret;
 }
 static int da9052_bat_remove(struct platform_device *pdev)
@@ -647,7 +647,6 @@ static int da9052_bat_remove(struct platform_device *pdev)
                da9052_free_irq(bat->da9052, da9052_bat_irq_bits[i], bat);
 
        power_supply_unregister(&bat->psy);
-       kfree(bat);
 
        return 0;
 }