Skip to content

Commit 7b8792b

Browse files
Hans Holmberglinusw
authored andcommitted
gpiolib: of: Correct error handling in of_get_named_gpiod_flags
of_get_named_gpiod_flags fails with -EPROBE_DEFER in cases where the gpio chip is available and the GPIO translation fails. This causes drivers to be re-probed erroneusly, and hides the real problem(i.e. the GPIO number being out of range). Cc: Stable <stable@vger.kernel.org> Signed-off-by: Hans Holmberg <hans.holmberg@intel.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent ebbeba1 commit 7b8792b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/gpio/gpiolib-of.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
4545
return false;
4646

4747
ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
48-
if (ret < 0)
49-
return false;
48+
if (ret < 0) {
49+
/* We've found the gpio chip, but the translation failed.
50+
* Return true to stop looking and return the translation
51+
* error via out_gpio
52+
*/
53+
gg_data->out_gpio = ERR_PTR(ret);
54+
return true;
55+
}
5056

5157
gg_data->out_gpio = gpiochip_get_desc(gc, ret);
5258
return true;

0 commit comments

Comments
 (0)