mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
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>
This commit is contained in:
parent
d1b6aecde4
commit
08eba5ba4f
1 changed files with 13 additions and 28 deletions
|
@ -294,7 +294,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
int ret;
|
int ret;
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
dev_err(&pdev->dev, "failed to allocate driver data\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -316,7 +316,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
if (!io[k]) {
|
if (!io[k]) {
|
||||||
dev_err(&pdev->dev, "not enough IOMEM resources\n");
|
dev_err(&pdev->dev, "not enough IOMEM resources\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err1;
|
goto err0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
if (p->number_of_irqs < 1) {
|
if (p->number_of_irqs < 1) {
|
||||||
dev_err(&pdev->dev, "not enough IRQ resources\n");
|
dev_err(&pdev->dev, "not enough IRQ resources\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err1;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ioremap IOMEM and setup read/write callbacks */
|
/* ioremap IOMEM and setup read/write callbacks */
|
||||||
|
@ -355,14 +355,15 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
default:
|
default:
|
||||||
dev_err(&pdev->dev, "IOMEM size mismatch\n");
|
dev_err(&pdev->dev, "IOMEM size mismatch\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err2;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i->iomem = ioremap_nocache(io[k]->start, resource_size(io[k]));
|
i->iomem = devm_ioremap_nocache(&pdev->dev, io[k]->start,
|
||||||
|
resource_size(io[k]));
|
||||||
if (!i->iomem) {
|
if (!i->iomem) {
|
||||||
dev_err(&pdev->dev, "failed to remap IOMEM\n");
|
dev_err(&pdev->dev, "failed to remap IOMEM\n");
|
||||||
ret = -ENXIO;
|
ret = -ENXIO;
|
||||||
goto err2;
|
goto err0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,17 +396,17 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
if (!p->irq_domain) {
|
if (!p->irq_domain) {
|
||||||
ret = -ENXIO;
|
ret = -ENXIO;
|
||||||
dev_err(&pdev->dev, "cannot initialize irq domain\n");
|
dev_err(&pdev->dev, "cannot initialize irq domain\n");
|
||||||
goto err2;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* request and set priority on interrupts one by one */
|
/* request and set priority on interrupts one by one */
|
||||||
for (k = 0; k < p->number_of_irqs; k++) {
|
for (k = 0; k < p->number_of_irqs; k++) {
|
||||||
if (request_irq(p->irq[k].requested_irq,
|
if (devm_request_irq(&pdev->dev, p->irq[k].requested_irq,
|
||||||
intc_irqpin_irq_handler,
|
intc_irqpin_irq_handler,
|
||||||
0, name, &p->irq[k])) {
|
0, name, &p->irq[k])) {
|
||||||
dev_err(&pdev->dev, "failed to request low IRQ\n");
|
dev_err(&pdev->dev, "failed to request low IRQ\n");
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto err3;
|
goto err1;
|
||||||
}
|
}
|
||||||
intc_irqpin_mask_unmask_prio(p, k, 0);
|
intc_irqpin_mask_unmask_prio(p, k, 0);
|
||||||
}
|
}
|
||||||
|
@ -421,16 +422,8 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err3:
|
|
||||||
for (; k >= 0; k--)
|
|
||||||
free_irq(p->irq[k - 1].requested_irq, &p->irq[k - 1]);
|
|
||||||
|
|
||||||
irq_domain_remove(p->irq_domain);
|
|
||||||
err2:
|
|
||||||
for (k = 0; k < INTC_IRQPIN_REG_NR; k++)
|
|
||||||
iounmap(p->iomem[k].iomem);
|
|
||||||
err1:
|
err1:
|
||||||
kfree(p);
|
irq_domain_remove(p->irq_domain);
|
||||||
err0:
|
err0:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -438,17 +431,9 @@ static int intc_irqpin_probe(struct platform_device *pdev)
|
||||||
static int intc_irqpin_remove(struct platform_device *pdev)
|
static int intc_irqpin_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
|
struct intc_irqpin_priv *p = platform_get_drvdata(pdev);
|
||||||
int k;
|
|
||||||
|
|
||||||
for (k = 0; k < p->number_of_irqs; k++)
|
|
||||||
free_irq(p->irq[k].requested_irq, &p->irq[k]);
|
|
||||||
|
|
||||||
irq_domain_remove(p->irq_domain);
|
irq_domain_remove(p->irq_domain);
|
||||||
|
|
||||||
for (k = 0; k < INTC_IRQPIN_REG_NR; k++)
|
|
||||||
iounmap(p->iomem[k].iomem);
|
|
||||||
|
|
||||||
kfree(p);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue