Commit 5297c693 authored by Florian Fainelli's avatar Florian Fainelli Committed by Linus Walleij

pinctrl: bcm2835: Fix a few error paths

After commit 266423e6 ("pinctrl: bcm2835: Change init order for gpio
hogs") a few error paths would not unwind properly the registration of
gpio ranges. Correct that by assigning a single error label and goto it
whenever we encounter a fatal error.

Fixes: 266423e6 ("pinctrl: bcm2835: Change init order for gpio hogs")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 474932a3
...@@ -1269,16 +1269,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) ...@@ -1269,16 +1269,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
sizeof(*girq->parents), sizeof(*girq->parents),
GFP_KERNEL); GFP_KERNEL);
if (!girq->parents) { if (!girq->parents) {
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); err = -ENOMEM;
return -ENOMEM; goto out_remove;
} }
if (is_7211) { if (is_7211) {
pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS, pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
sizeof(*pc->wake_irq), sizeof(*pc->wake_irq),
GFP_KERNEL); GFP_KERNEL);
if (!pc->wake_irq) if (!pc->wake_irq) {
return -ENOMEM; err = -ENOMEM;
goto out_remove;
}
} }
/* /*
...@@ -1306,8 +1308,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) ...@@ -1306,8 +1308,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
len = strlen(dev_name(pc->dev)) + 16; len = strlen(dev_name(pc->dev)) + 16;
name = devm_kzalloc(pc->dev, len, GFP_KERNEL); name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
if (!name) if (!name) {
return -ENOMEM; err = -ENOMEM;
goto out_remove;
}
snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i);
...@@ -1326,11 +1330,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev) ...@@ -1326,11 +1330,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
err = gpiochip_add_data(&pc->gpio_chip, pc); err = gpiochip_add_data(&pc->gpio_chip, pc);
if (err) { if (err) {
dev_err(dev, "could not add GPIO chip\n"); dev_err(dev, "could not add GPIO chip\n");
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); goto out_remove;
return err;
} }
return 0; return 0;
out_remove:
pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
return err;
} }
static struct platform_driver bcm2835_pinctrl_driver = { static struct platform_driver bcm2835_pinctrl_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment