pinctrl: qcom: remove gpiochip in failure cases
authorPramod Gurav <pramod.gurav@smartplayin.com>
Fri, 29 Aug 2014 08:11:48 +0000 (13:41 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 2 Sep 2014 12:27:40 +0000 (14:27 +0200)
This patch releases gpiochip related resources by calling
gpiochip_remove when either of gpiochip_add_pin_range and
gpiochip_irqchip_add fails.

CC: Linus Walleij <linus.walleij@linaro.org>
CC: "Ivan T. Ivanov" <iivanov@mm-sol.com>
Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-msm.c

index 2738108caff2be08c02ea198f6364f0c912c19a1..9175bbc298c71394858ba016edf2beb5b99af555 100644 (file)
@@ -829,6 +829,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
        ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), 0, 0, chip->ngpio);
        if (ret) {
                dev_err(pctrl->dev, "Failed to add pin range\n");
+               gpiochip_remove(&pctrl->chip);
                return ret;
        }
 
@@ -839,6 +840,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
                                   IRQ_TYPE_NONE);
        if (ret) {
                dev_err(pctrl->dev, "Failed to add irqchip to gpiochip\n");
+               gpiochip_remove(&pctrl->chip);
                return -ENOSYS;
        }