diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2017-04-10 09:35:30 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-04-10 09:35:30 +0200 |
commit | 8d4264d86c1a31d7e0efd3e4c3e08bc91dbdb48c (patch) | |
tree | 54f74ed92952148c9923d70471e7cbc62b9e57d6 /drivers/pinctrl/samsung/pinctrl-samsung.c | |
parent | ba9e7f2794d8158c93aacd279830a6f1f98b19b0 (diff) | |
parent | f69ae4f58a198ad15b0422637434d2bcf6fc2e2a (diff) | |
download | linux-8d4264d86c1a31d7e0efd3e4c3e08bc91dbdb48c.tar.gz linux-8d4264d86c1a31d7e0efd3e4c3e08bc91dbdb48c.tar.bz2 linux-8d4264d86c1a31d7e0efd3e4c3e08bc91dbdb48c.zip |
Merge tag 'samsung-pinctrl-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/samsung into devel
Samsung pinctrl drivers update for v4.12:
1. Add support for pad retention control through pinctrl drivers which
moves us forward to better runtime PM of pinctrl, clocks, power domains
and other devices.
2. Fix GPIO hogs by registering pinctrl before registering gpiolib.
3. Use devm-like interface.
Diffstat (limited to 'drivers/pinctrl/samsung/pinctrl-samsung.c')
-rw-r--r-- | drivers/pinctrl/samsung/pinctrl-samsung.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 0d2989d98bc3..b618dae84cec 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -882,7 +882,7 @@ static int samsung_pinctrl_register(struct platform_device *pdev, pin_bank->grange.id = bank; pin_bank->grange.pin_base = drvdata->pin_base + pin_bank->pin_base; - pin_bank->grange.base = pin_bank->gpio_chip.base; + pin_bank->grange.base = pin_bank->grange.pin_base; pin_bank->grange.npins = pin_bank->gpio_chip.ngpio; pin_bank->grange.gc = &pin_bank->gpio_chip; pinctrl_add_gpio_range(drvdata->pctl_dev, &pin_bank->grange); @@ -891,6 +891,19 @@ static int samsung_pinctrl_register(struct platform_device *pdev, return 0; } +/* unregister the pinctrl interface with the pinctrl subsystem */ +static int samsung_pinctrl_unregister(struct platform_device *pdev, + struct samsung_pinctrl_drv_data *drvdata) +{ + struct samsung_pin_bank *bank = drvdata->pin_banks; + int i; + + for (i = 0; i < drvdata->nr_banks; ++i, ++bank) + pinctrl_remove_gpio_range(drvdata->pctl_dev, &bank->grange); + + return 0; +} + static const struct gpio_chip samsung_gpiolib_chip = { .request = gpiochip_generic_request, .free = gpiochip_generic_free, @@ -915,39 +928,21 @@ static int samsung_gpiolib_register(struct platform_device *pdev, bank->gpio_chip = samsung_gpiolib_chip; gc = &bank->gpio_chip; - gc->base = drvdata->pin_base + bank->pin_base; + gc->base = bank->grange.base; gc->ngpio = bank->nr_pins; gc->parent = &pdev->dev; gc->of_node = bank->of_node; gc->label = bank->name; - ret = gpiochip_add_data(gc, bank); + ret = devm_gpiochip_add_data(&pdev->dev, gc, bank); if (ret) { dev_err(&pdev->dev, "failed to register gpio_chip %s, error code: %d\n", gc->label, ret); - goto fail; + return ret; } } return 0; - -fail: - for (--i, --bank; i >= 0; --i, --bank) - gpiochip_remove(&bank->gpio_chip); - return ret; -} - -/* unregister the gpiolib interface with the gpiolib subsystem */ -static int samsung_gpiolib_unregister(struct platform_device *pdev, - struct samsung_pinctrl_drv_data *drvdata) -{ - struct samsung_pin_bank *bank = drvdata->pin_banks; - int i; - - for (i = 0; i < drvdata->nr_banks; ++i, ++bank) - gpiochip_remove(&bank->gpio_chip); - - return 0; } /* retrieve the soc specific data */ @@ -1060,13 +1055,13 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) return PTR_ERR(drvdata->retention_ctrl); } - ret = samsung_gpiolib_register(pdev, drvdata); + ret = samsung_pinctrl_register(pdev, drvdata); if (ret) return ret; - ret = samsung_pinctrl_register(pdev, drvdata); + ret = samsung_gpiolib_register(pdev, drvdata); if (ret) { - samsung_gpiolib_unregister(pdev, drvdata); + samsung_pinctrl_unregister(pdev, drvdata); return ret; } |