提交 b92ff855 编写于 作者: J Jingoo Han 提交者: Anton Vorontsov

gpio-charger: Use devm_kzalloc()

Use devm_kzalloc() to make cleanup paths more simple.
Signed-off-by: NJingoo Han <jg1.han@samsung.com>
Signed-off-by: NAnton Vorontsov <anton@enomsg.org>
上级 2a2ce52a
...@@ -86,7 +86,8 @@ static int gpio_charger_probe(struct platform_device *pdev) ...@@ -86,7 +86,8 @@ static int gpio_charger_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
gpio_charger = kzalloc(sizeof(*gpio_charger), GFP_KERNEL); gpio_charger = devm_kzalloc(&pdev->dev, sizeof(*gpio_charger),
GFP_KERNEL);
if (!gpio_charger) { if (!gpio_charger) {
dev_err(&pdev->dev, "Failed to alloc driver structure\n"); dev_err(&pdev->dev, "Failed to alloc driver structure\n");
return -ENOMEM; return -ENOMEM;
...@@ -140,7 +141,6 @@ static int gpio_charger_probe(struct platform_device *pdev) ...@@ -140,7 +141,6 @@ static int gpio_charger_probe(struct platform_device *pdev)
err_gpio_free: err_gpio_free:
gpio_free(pdata->gpio); gpio_free(pdata->gpio);
err_free: err_free:
kfree(gpio_charger);
return ret; return ret;
} }
...@@ -156,7 +156,6 @@ static int gpio_charger_remove(struct platform_device *pdev) ...@@ -156,7 +156,6 @@ static int gpio_charger_remove(struct platform_device *pdev)
gpio_free(gpio_charger->pdata->gpio); gpio_free(gpio_charger->pdata->gpio);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(gpio_charger);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册