Re: [PATCH] pinctrl: pistachio: Use common error handling code in pistachio_gpio_register()
From: Dan Carpenter
Date: Wed Nov 01 2017 - 06:19:13 EST
On Mon, Oct 30, 2017 at 06:51:19PM +0100, SF Markus Elfring wrote:
> @@ -1409,13 +1408,15 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
> if (ret < 0) {
> dev_err(pctl->dev, "Failed to add GPIO range %u: %d\n",
> i, ret);
> - gpiochip_remove(&bank->gpio_chip);
> - goto err;
> + goto remove_chip;
It's better code to put the gpiochip_remove() before the goto, because
say we want to add more error handling before the remove_chip: label.
Now it doesn't work.
> }
> }
>
> return 0;
> -err:
> +
> +remove_chip:
> + gpiochip_remove(&bank->gpio_chip);
> +remove_chips:
> for (; i > 0; i--) {
> bank = &pctl->gpio_banks[i - 1];
> gpiochip_remove(&bank->gpio_chip);
regards,
dan carpenter