gpio-charger: Use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Mon, 11 Mar 2013 06:33:27 +0000 (15:33 +0900)
committerAnton Vorontsov <anton@enomsg.org>
Mon, 1 Apr 2013 06:25:42 +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/gpio-charger.c

index e3e40a9f3af2a962e39a4f4687359e348bc87d11..e9883eeeee76a0506a9b891ddcdf19320ce2d6b3 100644 (file)
@@ -86,7 +86,8 @@ static int gpio_charger_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       gpio_charger = kzalloc(sizeof(*gpio_charger), GFP_KERNEL);
+       gpio_charger = devm_kzalloc(&pdev->dev, sizeof(*gpio_charger),
+                                       GFP_KERNEL);
        if (!gpio_charger) {
                dev_err(&pdev->dev, "Failed to alloc driver structure\n");
                return -ENOMEM;
@@ -140,7 +141,6 @@ static int gpio_charger_probe(struct platform_device *pdev)
 err_gpio_free:
        gpio_free(pdata->gpio);
 err_free:
-       kfree(gpio_charger);
        return ret;
 }
 
@@ -156,7 +156,6 @@ static int gpio_charger_remove(struct platform_device *pdev)
        gpio_free(gpio_charger->pdata->gpio);
 
        platform_set_drvdata(pdev, NULL);
-       kfree(gpio_charger);
 
        return 0;
 }
This page took 0.024888 seconds and 5 git commands to generate.