aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/jz4740-battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/jz4740-battery.c')
-rw-r--r--drivers/power/jz4740-battery.c14
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)
250 return -ENXIO; 250 return -ENXIO;
251 } 251 }
252 252
253 jz_battery = kzalloc(sizeof(*jz_battery), GFP_KERNEL); 253 jz_battery = devm_kzalloc(&pdev->dev, sizeof(*jz_battery), GFP_KERNEL);
254 if (!jz_battery) { 254 if (!jz_battery) {
255 dev_err(&pdev->dev, "Failed to allocate driver structure\n"); 255 dev_err(&pdev->dev, "Failed to allocate driver structure\n");
256 return -ENOMEM; 256 return -ENOMEM;
@@ -260,24 +260,21 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
260 260
261 jz_battery->irq = platform_get_irq(pdev, 0); 261 jz_battery->irq = platform_get_irq(pdev, 0);
262 if (jz_battery->irq < 0) { 262 if (jz_battery->irq < 0) {
263 ret = jz_battery->irq;
264 dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret); 263 dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret);
265 goto err_free; 264 return jz_battery->irq;
266 } 265 }
267 266
268 jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 267 jz_battery->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
269 if (!jz_battery->mem) { 268 if (!jz_battery->mem) {
270 ret = -ENOENT;
271 dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); 269 dev_err(&pdev->dev, "Failed to get platform mmio resource\n");
272 goto err_free; 270 return -ENOENT;
273 } 271 }
274 272
275 jz_battery->mem = request_mem_region(jz_battery->mem->start, 273 jz_battery->mem = request_mem_region(jz_battery->mem->start,
276 resource_size(jz_battery->mem), pdev->name); 274 resource_size(jz_battery->mem), pdev->name);
277 if (!jz_battery->mem) { 275 if (!jz_battery->mem) {
278 ret = -EBUSY;
279 dev_err(&pdev->dev, "Failed to request mmio memory region\n"); 276 dev_err(&pdev->dev, "Failed to request mmio memory region\n");
280 goto err_free; 277 return -EBUSY;
281 } 278 }
282 279
283 jz_battery->base = ioremap_nocache(jz_battery->mem->start, 280 jz_battery->base = ioremap_nocache(jz_battery->mem->start,
@@ -371,8 +368,6 @@ err_iounmap:
371 iounmap(jz_battery->base); 368 iounmap(jz_battery->base);
372err_release_mem_region: 369err_release_mem_region:
373 release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem)); 370 release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
374err_free:
375 kfree(jz_battery);
376 return ret; 371 return ret;
377} 372}
378 373
@@ -394,7 +389,6 @@ static int __devexit jz_battery_remove(struct platform_device *pdev)
394 389
395 iounmap(jz_battery->base); 390 iounmap(jz_battery->base);
396 release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem)); 391 release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
397 kfree(jz_battery);
398 392
399 return 0; 393 return 0;
400} 394}