Commit 91da7032 authored by Rob Herring's avatar Rob Herring Committed by Linus Walleij

pinctrl: at91: fix deferred probing support

AT91 pinctrl deferred probing support is broken if the GPIO devices
haven't probed first and set gpio_banks to non-zero. The later condition
that only some GPIO devices haven't probed can't actually happen as
either all the GPIO devices have probed first or none of them have. Plus
the pinctrl driver has already returned -EINVAL, so it's not on the
deferred list to retry probing.

Fix this by consolidating the checking that all GPIO devices are probed.

Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-gpio@vger.kernel.org
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
Tested-by: Nicolas Ferre <nicolas.ferre@microchip.com> # on sama5d3 xplained
Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20180712192222.32481-1-robh@kernel.orgSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6c488fbb
...@@ -1294,7 +1294,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, ...@@ -1294,7 +1294,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
struct at91_pinctrl *info) struct at91_pinctrl *info)
{ {
int ret = 0; int ret = 0;
int i, j; int i, j, ngpio_chips_enabled = 0;
uint32_t *tmp; uint32_t *tmp;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *child; struct device_node *child;
...@@ -1307,10 +1307,17 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, ...@@ -1307,10 +1307,17 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; of_match_device(at91_pinctrl_of_match, &pdev->dev)->data;
at91_pinctrl_child_count(info, np); at91_pinctrl_child_count(info, np);
if (gpio_banks < 1) { /*
dev_err(&pdev->dev, "you need to specify at least one gpio-controller\n"); * We need all the GPIO drivers to probe FIRST, or we will not be able
return -EINVAL; * to obtain references to the struct gpio_chip * for them, and we
} * need this to proceed.
*/
for (i = 0; i < MAX_GPIO_BANKS; i++)
if (gpio_chips[i])
ngpio_chips_enabled++;
if (ngpio_chips_enabled < info->nactive_banks)
return -EPROBE_DEFER;
ret = at91_pinctrl_mux_mask(info, np); ret = at91_pinctrl_mux_mask(info, np);
if (ret) if (ret)
...@@ -1366,7 +1373,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev) ...@@ -1366,7 +1373,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
{ {
struct at91_pinctrl *info; struct at91_pinctrl *info;
struct pinctrl_pin_desc *pdesc; struct pinctrl_pin_desc *pdesc;
int ret, i, j, k, ngpio_chips_enabled = 0; int ret, i, j, k;
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) if (!info)
...@@ -1376,23 +1383,6 @@ static int at91_pinctrl_probe(struct platform_device *pdev) ...@@ -1376,23 +1383,6 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
/*
* We need all the GPIO drivers to probe FIRST, or we will not be able
* to obtain references to the struct gpio_chip * for them, and we
* need this to proceed.
*/
for (i = 0; i < gpio_banks; i++)
if (gpio_chips[i])
ngpio_chips_enabled++;
if (ngpio_chips_enabled < info->nactive_banks) {
dev_warn(&pdev->dev,
"All GPIO chips are not registered yet (%d/%d)\n",
ngpio_chips_enabled, info->nactive_banks);
devm_kfree(&pdev->dev, info);
return -EPROBE_DEFER;
}
at91_pinctrl_desc.name = dev_name(&pdev->dev); at91_pinctrl_desc.name = dev_name(&pdev->dev);
at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK;
at91_pinctrl_desc.pins = pdesc = at91_pinctrl_desc.pins = pdesc =
......
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