pinctrl: spmi-gpio: Use devm_pinctrl_register() for pinctrl registration
authorLaxman Dewangan <ldewangan@nvidia.com>
Wed, 24 Feb 2016 09:14:07 +0000 (14:44 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 20 Apr 2016 22:02:46 +0000 (00:02 +0200)
Use devm_pinctrl_register() for pin control registration and clean
the error path.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Cc: "Björn Andersson" <bjorn.andersson@sonymobile.com>
Cc: "Ivan T. Ivanov" <ivan.ivanov@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Jonas Gorski <jogo@openwrt.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

index 857ccfa67986c5b5bf0ec363f366ab681cc10b8e..686accb89f527a358d93129d660ae107f89f2e06 100644 (file)
@@ -764,14 +764,14 @@ static int pmic_gpio_probe(struct platform_device *pdev)
        state->chip.of_gpio_n_cells = 2;
        state->chip.can_sleep = false;
 
-       state->ctrl = pinctrl_register(pctrldesc, dev, state);
+       state->ctrl = devm_pinctrl_register(dev, pctrldesc, state);
        if (IS_ERR(state->ctrl))
                return PTR_ERR(state->ctrl);
 
        ret = gpiochip_add_data(&state->chip, state);
        if (ret) {
                dev_err(state->dev, "can't add gpio chip\n");
-               goto err_chip;
+               return ret;
        }
 
        ret = gpiochip_add_pin_range(&state->chip, dev_name(dev), 0, 0, npins);
@@ -784,8 +784,6 @@ static int pmic_gpio_probe(struct platform_device *pdev)
 
 err_range:
        gpiochip_remove(&state->chip);
-err_chip:
-       pinctrl_unregister(state->ctrl);
        return ret;
 }
 
@@ -794,7 +792,6 @@ static int pmic_gpio_remove(struct platform_device *pdev)
        struct pmic_gpio_state *state = platform_get_drvdata(pdev);
 
        gpiochip_remove(&state->chip);
-       pinctrl_unregister(state->ctrl);
        return 0;
 }