diff options
author | Marcos Paulo de Souza <marcos.souza.org@gmail.com> | 2012-11-06 21:11:11 -0200 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-11-18 16:10:36 -0800 |
commit | ec073c9b319fee6564dcb9f1fb7a70eb6a8a06b5 (patch) | |
tree | aa49d2301d012d3dd07567410339b6a784fcee49 /drivers/power/jz4740-battery.c | |
parent | e59ec4a1899dfff007d91b30f00e7211731b816b (diff) | |
download | linux-ec073c9b319fee6564dcb9f1fb7a70eb6a8a06b5.tar.bz2 |
jz4740-battery: Use devm_kzalloc
This is just a small cleanup, makes a logic a little bit more simplier.
Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/jz4740-battery.c')
-rw-r--r-- | drivers/power/jz4740-battery.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c index ffbed5e5b945..529d22abe0e2 100644 --- a/drivers/power/jz4740-battery.c +++ b/drivers/power/jz4740-battery.c @@ -250,7 +250,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev) return -ENXIO; } - jz_battery = kzalloc(sizeof(*jz_battery), GFP_KERNEL); + jz_battery = devm_kzalloc(&pdev->dev, sizeof(*jz_battery), GFP_KERNEL); if (!jz_battery) { dev_err(&pdev->dev, "Failed to allocate driver structure\n"); return -ENOMEM; @@ -260,24 +260,21 @@ static int __devinit jz_battery_probe(struct platform_device *pdev) jz_battery->irq = platform_get_irq(pdev, 0); if (jz_battery->irq < 0) { - ret = jz_battery->irq; dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret); - goto err_free; + return jz_battery->irq; } jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!jz_battery->mem) { - ret = -ENOENT; dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); - goto err_free; + return -ENOENT; } jz_battery->mem = request_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem), pdev->name); if (!jz_battery->mem) { - ret = -EBUSY; dev_err(&pdev->dev, "Failed to request mmio memory region\n"); - goto err_free; + return -EBUSY; } jz_battery->base = ioremap_nocache(jz_battery->mem->start, @@ -371,8 +368,6 @@ err_iounmap: iounmap(jz_battery->base); err_release_mem_region: release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem)); -err_free: - kfree(jz_battery); return ret; } @@ -394,7 +389,6 @@ static int __devexit jz_battery_remove(struct platform_device *pdev) iounmap(jz_battery->base); release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem)); - kfree(jz_battery); return 0; } |