Skip to content

Commit 1dea33e

Browse files
dtorlinusw
authored andcommitted
gpiolib: of: fix fallback quirks handling
We should only try to execute fallback quirks handling when previous call returned -ENOENT, and not when we did not get -EPROBE_DEFER. The other errors should be treated as hard errors: we did find the GPIO description, but for some reason we failed to handle it properly. The fallbacks should only be executed when previous handlers returned -ENOENT, which means the mapping/description was not found. Also let's remove the explicit deferral handling when iterating through GPIO suffixes: it is not needed anymore as we will not be calling fallbacks for anything but -ENOENT. Fixes: df451f8 ("gpio: of: fix Freescale SPI CS quirk handling") Signed-off-by: Dmitry Torokhov <[email protected]> Link: https://lore.kernel.org/r/20190903231856.GA165165@dtor-ws Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent aefde29 commit 1dea33e

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

drivers/gpio/gpiolib-of.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -343,36 +343,27 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
343343

344344
desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
345345
&of_flags);
346-
/*
347-
* -EPROBE_DEFER in our case means that we found a
348-
* valid GPIO property, but no controller has been
349-
* registered so far.
350-
*
351-
* This means we don't need to look any further for
352-
* alternate name conventions, and we should really
353-
* preserve the return code for our user to be able to
354-
* retry probing later.
355-
*/
356-
if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER)
357-
return desc;
358346

359-
if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
347+
if (!IS_ERR(desc) || PTR_ERR(desc) != -ENOENT)
360348
break;
361349
}
362350

363-
/* Special handling for SPI GPIOs if used */
364-
if (IS_ERR(desc))
351+
if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
352+
/* Special handling for SPI GPIOs if used */
365353
desc = of_find_spi_gpio(dev, con_id, &of_flags);
366-
if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) {
354+
}
355+
356+
if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
367357
/* This quirk looks up flags and all */
368358
desc = of_find_spi_cs_gpio(dev, con_id, idx, flags);
369359
if (!IS_ERR(desc))
370360
return desc;
371361
}
372362

373-
/* Special handling for regulator GPIOs if used */
374-
if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
363+
if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) {
364+
/* Special handling for regulator GPIOs if used */
375365
desc = of_find_regulator_gpio(dev, con_id, &of_flags);
366+
}
376367

377368
if (IS_ERR(desc))
378369
return desc;

0 commit comments

Comments
 (0)