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

index e757885b620c5c6cf00639fc6a5952631308041b..4bdedfed936d87ab55cc1c7c1b7c84e884361fd6 100644 (file)
@@ -138,7 +138,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
                return ret;
        }
 
-       charger = kzalloc(sizeof(struct charger_data), GFP_KERNEL);
+       charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
+                               GFP_KERNEL);
        if (charger == NULL) {
                dev_err(&pdev->dev, "Cannot allocate memory.\n");
                return -ENOMEM;
@@ -158,13 +159,10 @@ static int max8997_battery_probe(struct platform_device *pdev)
        ret = power_supply_register(&pdev->dev, &charger->battery);
        if (ret) {
                dev_err(&pdev->dev, "failed: power supply register\n");
-               goto err;
+               return ret;
        }
 
        return 0;
-err:
-       kfree(charger);
-       return ret;
 }
 
 static int max8997_battery_remove(struct platform_device *pdev)
@@ -172,7 +170,6 @@ static int max8997_battery_remove(struct platform_device *pdev)
        struct charger_data *charger = platform_get_drvdata(pdev);
 
        power_supply_unregister(&charger->battery);
-       kfree(charger);
        return 0;
 }