Message ID | 1455876050-5481-1-git-send-email-geert+renesas@glider.be |
---|---|
State | New |
Headers | show |
On Fri, Feb 19, 2016 at 11:00 AM, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > devm_get_gpiod_from_child() tries several property suffixes to find a > GPIO descriptor. If all suffixes fail and no probe deferral has been > detected, it returns the error of the last try. > > However, if any but the last try fails with a real error (e.g. -EBUSY), > this error is not propagated, and -ENOENT will be returned. > This confuses drivers that e.g. want to detect if a GPIO is already in > use. > > To fix this, change the loop logic to continue on -ENOENT, which > indicates the property was not found and the next suffix should be > tried, and propagate all other detected errors. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Patch applied. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 903fcf4d04a06e55..b760cbbb41d82490 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c @@ -155,7 +155,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, suffixes[i]); desc = fwnode_get_named_gpiod(child, prop_name); - if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER)) + if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) break; } if (IS_ERR(desc)) {
devm_get_gpiod_from_child() tries several property suffixes to find a GPIO descriptor. If all suffixes fail and no probe deferral has been detected, it returns the error of the last try. However, if any but the last try fails with a real error (e.g. -EBUSY), this error is not propagated, and -ENOENT will be returned. This confuses drivers that e.g. want to detect if a GPIO is already in use. To fix this, change the loop logic to continue on -ENOENT, which indicates the property was not found and the next suffix should be tried, and propagate all other detected errors. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/gpio/devres.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)