gpio: em: Return early on error in em_gio_probe()

em_gio_probe() uses managed initializations for everything but creating
the IRQ domain.  Hence in most failure cases, no cleanup needs to be
performed at all.

Make this clearer for the casual reviewer by returning early, instead of
jumping to an out-of-sight label.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
This commit is contained in:
Geert Uytterhoeven 2019-05-27 14:40:51 +02:00 committed by Bartosz Golaszewski
parent 4c411ce35b
commit 715ed72801

View File

@ -282,10 +282,8 @@ static int em_gio_probe(struct platform_device *pdev)
int ret; int ret;
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
if (!p) { if (!p)
ret = -ENOMEM; return -ENOMEM;
goto err0;
}
p->pdev = pdev; p->pdev = pdev;
platform_set_drvdata(pdev, p); platform_set_drvdata(pdev, p);
@ -298,28 +296,22 @@ static int em_gio_probe(struct platform_device *pdev)
if (!io[0] || !io[1] || !irq[0] || !irq[1]) { if (!io[0] || !io[1] || !irq[0] || !irq[1]) {
dev_err(&pdev->dev, "missing IRQ or IOMEM\n"); dev_err(&pdev->dev, "missing IRQ or IOMEM\n");
ret = -EINVAL; return -EINVAL;
goto err0;
} }
p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start, p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start,
resource_size(io[0])); resource_size(io[0]));
if (!p->base0) { if (!p->base0)
ret = -ENOMEM; return -ENOMEM;
goto err0;
}
p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start, p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start,
resource_size(io[1])); resource_size(io[1]));
if (!p->base1) { if (!p->base1)
ret = -ENOMEM; return -ENOMEM;
goto err0;
}
if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) {
dev_err(&pdev->dev, "Missing ngpios OF property\n"); dev_err(&pdev->dev, "Missing ngpios OF property\n");
ret = -EINVAL; return -EINVAL;
goto err0;
} }
gpio_chip = &p->gpio_chip; gpio_chip = &p->gpio_chip;
@ -349,9 +341,8 @@ static int em_gio_probe(struct platform_device *pdev)
p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0, p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0,
&em_gio_irq_domain_ops, p); &em_gio_irq_domain_ops, p);
if (!p->irq_domain) { if (!p->irq_domain) {
ret = -ENXIO;
dev_err(&pdev->dev, "cannot initialize irq domain\n"); dev_err(&pdev->dev, "cannot initialize irq domain\n");
goto err0; return -ENXIO;
} }
if (devm_request_irq(&pdev->dev, irq[0]->start, if (devm_request_irq(&pdev->dev, irq[0]->start,
@ -378,7 +369,6 @@ static int em_gio_probe(struct platform_device *pdev)
err1: err1:
irq_domain_remove(p->irq_domain); irq_domain_remove(p->irq_domain);
err0:
return ret; return ret;
} }