aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/irqchip
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2013-02-26 06:59:13 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-03-18 08:26:06 -0400
commit08eba5ba4f321c4b1806ecad0e626904f89263a1 (patch)
treed0f70d249f7e5c6b05534017ca9129f67b1f18de /drivers/irqchip
parentd1b6aecde4ab146d115abcaf3bb1940d8e980b5a (diff)
irqchip: intc-irqpin: Make use of devm functions
Use devm_kzalloc(), devm_ioremap_nocache() and devm_request_irq() to simplify error handling. Signed-off-by: Magnus Damm <damm@opensource.se> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/irqchip')
-rw-r--r--drivers/irqchip/irq-renesas-intc-irqpin.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/irqchip/irq-renesas-intc-irqpin.c b/drivers/irqchip/irq-renesas-intc-irqpin.c
index 59c0cbccf212..21f46027f39a 100644
--- a/drivers/irqchip/irq-renesas-intc-irqpin.c
+++ b/drivers/irqchip/irq-renesas-intc-irqpin.c
@@ -294,7 +294,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
294 int ret; 294 int ret;
295 int k; 295 int k;
296 296
297 p = kzalloc(sizeof(*p), GFP_KERNEL); 297 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
298 if (!p) { 298 if (!p) {
299 dev_err(&pdev->dev, "failed to allocate driver data\n"); 299 dev_err(&pdev->dev, "failed to allocate driver data\n");
300 ret = -ENOMEM; 300 ret = -ENOMEM;
@@ -316,7 +316,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
316 if (!io[k]) { 316 if (!io[k]) {
317 dev_err(&pdev->dev, "not enough IOMEM resources\n"); 317 dev_err(&pdev->dev, "not enough IOMEM resources\n");
318 ret = -EINVAL; 318 ret = -EINVAL;
319 goto err1; 319 goto err0;
320 } 320 }
321 } 321 }
322 322
@@ -334,7 +334,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
334 if (p->number_of_irqs < 1) { 334 if (p->number_of_irqs < 1) {
335 dev_err(&pdev->dev, "not enough IRQ resources\n"); 335 dev_err(&pdev->dev, "not enough IRQ resources\n");
336 ret = -EINVAL; 336 ret = -EINVAL;
337 goto err1; 337 goto err0;
338 } 338 }
339 339
340 /* ioremap IOMEM and setup read/write callbacks */ 340 /* ioremap IOMEM and setup read/write callbacks */
@@ -355,14 +355,15 @@ static int intc_irqpin_probe(struct platform_device *pdev)
355 default: 355 default:
356 dev_err(&pdev->dev, "IOMEM size mismatch\n"); 356 dev_err(&pdev->dev, "IOMEM size mismatch\n");
357 ret = -EINVAL; 357 ret = -EINVAL;
358 goto err2; 358 goto err0;
359 } 359 }
360 360
361 i->iomem = ioremap_nocache(io[k]->start, resource_size(io[k])); 361 i->iomem = devm_ioremap_nocache(&pdev->dev, io[k]->start,
362 resource_size(io[k]));
362 if (!i->iomem) { 363 if (!i->iomem) {
363 dev_err(&pdev->dev, "failed to remap IOMEM\n"); 364 dev_err(&pdev->dev, "failed to remap IOMEM\n");
364 ret = -ENXIO; 365 ret = -ENXIO;
365 goto err2; 366 goto err0;
366 } 367 }
367 } 368 }
368 369
@@ -395,17 +396,17 @@ static int intc_irqpin_probe(struct platform_device *pdev)
395 if (!p->irq_domain) { 396 if (!p->irq_domain) {
396 ret = -ENXIO; 397 ret = -ENXIO;
397 dev_err(&pdev->dev, "cannot initialize irq domain\n"); 398 dev_err(&pdev->dev, "cannot initialize irq domain\n");
398 goto err2; 399 goto err0;
399 } 400 }
400 401
401 /* request and set priority on interrupts one by one */ 402 /* request and set priority on interrupts one by one */
402 for (k = 0; k < p->number_of_irqs; k++) { 403 for (k = 0; k < p->number_of_irqs; k++) {
403 if (request_irq(p->irq[k].requested_irq, 404 if (devm_request_irq(&pdev->dev, p->irq[k].requested_irq,
404 intc_irqpin_irq_handler, 405 intc_irqpin_irq_handler,
405 0, name, &p->irq[k])) { 406 0, name, &p->irq[k])) {
406 dev_err(&pdev->dev, "failed to request low IRQ\n"); 407 dev_err(&pdev->dev, "failed to request low IRQ\n");
407 ret = -ENOENT; 408 ret = -ENOENT;
408 goto err3; 409 goto err1;
409 } 410 }
410 intc_irqpin_mask_unmask_prio(p, k, 0); 411 intc_irqpin_mask_unmask_prio(p, k, 0);
411 } 412 }
@@ -421,16 +422,8 @@ static int intc_irqpin_probe(struct platform_device *pdev)
421 422
422 return 0; 423 return 0;
423 424
424err3:
425 for (; k >= 0; k--)
426 free_irq(p->irq[k - 1].requested_irq, &p->irq[k - 1]);
427
428 irq_domain_remove(p->irq_domain);
429err2:
430 for (k = 0; k < INTC_IRQPIN_REG_NR; k++)
431 iounmap(p->iomem[k].iomem);
432err1: 425err1:
433 kfree(p); 426 irq_domain_remove(p->irq_domain);
434err0: 427err0:
435 return ret; 428 return ret;
436} 429}
@@ -438,17 +431,9 @@ err0:
438static int intc_irqpin_remove(struct platform_device *pdev) 431static int intc_irqpin_remove(struct platform_device *pdev)
439{ 432{
440 struct intc_irqpin_priv *p = platform_get_drvdata(pdev); 433 struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
441 int k;
442
443 for (k = 0; k < p->number_of_irqs; k++)
444 free_irq(p->irq[k].requested_irq, &p->irq[k]);
445 434
446 irq_domain_remove(p->irq_domain); 435 irq_domain_remove(p->irq_domain);
447 436
448 for (k = 0; k < INTC_IRQPIN_REG_NR; k++)
449 iounmap(p->iomem[k].iomem);
450
451 kfree(p);
452 return 0; 437 return 0;
453} 438}
454 439