gpio: adp5520: use devm_kzalloc()

Use devm_kzalloc() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Jingoo Han 2013-03-15 18:14:01 +09:00 committed by Linus Walleij
parent 808c513ee6
commit 24bb3813d5

View File

@ -105,7 +105,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL) {
dev_err(&pdev->dev, "failed to alloc memory\n"); dev_err(&pdev->dev, "failed to alloc memory\n");
return -ENOMEM; return -ENOMEM;
@ -163,7 +163,6 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
return 0; return 0;
err: err:
kfree(dev);
return ret; return ret;
} }
@ -180,7 +179,6 @@ static int adp5520_gpio_remove(struct platform_device *pdev)
return ret; return ret;
} }
kfree(dev);
return 0; return 0;
} }