Skip to content

Commit 91da703

Browse files
robherringlinusw
authored andcommitted
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 <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Nicolas Ferre <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Rob Herring <[email protected]> Acked-by: Ludovic Desroches <[email protected]> Tested-by: Nicolas Ferre <[email protected]> # on sama5d3 xplained Acked-by: Nicolas Ferre <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 6c488fb commit 91da703

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

drivers/pinctrl/pinctrl-at91.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
12941294
struct at91_pinctrl *info)
12951295
{
12961296
int ret = 0;
1297-
int i, j;
1297+
int i, j, ngpio_chips_enabled = 0;
12981298
uint32_t *tmp;
12991299
struct device_node *np = pdev->dev.of_node;
13001300
struct device_node *child;
@@ -1307,10 +1307,17 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
13071307
of_match_device(at91_pinctrl_of_match, &pdev->dev)->data;
13081308
at91_pinctrl_child_count(info, np);
13091309

1310-
if (gpio_banks < 1) {
1311-
dev_err(&pdev->dev, "you need to specify at least one gpio-controller\n");
1312-
return -EINVAL;
1313-
}
1310+
/*
1311+
* We need all the GPIO drivers to probe FIRST, or we will not be able
1312+
* to obtain references to the struct gpio_chip * for them, and we
1313+
* need this to proceed.
1314+
*/
1315+
for (i = 0; i < MAX_GPIO_BANKS; i++)
1316+
if (gpio_chips[i])
1317+
ngpio_chips_enabled++;
1318+
1319+
if (ngpio_chips_enabled < info->nactive_banks)
1320+
return -EPROBE_DEFER;
13141321

13151322
ret = at91_pinctrl_mux_mask(info, np);
13161323
if (ret)
@@ -1366,7 +1373,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
13661373
{
13671374
struct at91_pinctrl *info;
13681375
struct pinctrl_pin_desc *pdesc;
1369-
int ret, i, j, k, ngpio_chips_enabled = 0;
1376+
int ret, i, j, k;
13701377

13711378
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
13721379
if (!info)
@@ -1376,23 +1383,6 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
13761383
if (ret)
13771384
return ret;
13781385

1379-
/*
1380-
* We need all the GPIO drivers to probe FIRST, or we will not be able
1381-
* to obtain references to the struct gpio_chip * for them, and we
1382-
* need this to proceed.
1383-
*/
1384-
for (i = 0; i < gpio_banks; i++)
1385-
if (gpio_chips[i])
1386-
ngpio_chips_enabled++;
1387-
1388-
if (ngpio_chips_enabled < info->nactive_banks) {
1389-
dev_warn(&pdev->dev,
1390-
"All GPIO chips are not registered yet (%d/%d)\n",
1391-
ngpio_chips_enabled, info->nactive_banks);
1392-
devm_kfree(&pdev->dev, info);
1393-
return -EPROBE_DEFER;
1394-
}
1395-
13961386
at91_pinctrl_desc.name = dev_name(&pdev->dev);
13971387
at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK;
13981388
at91_pinctrl_desc.pins = pdesc =

0 commit comments

Comments
 (0)