diff mbox

gpiolib: of: Correct error handling in of_get_named_gpiod_flags

Message ID 1420792844-27781-1-git-send-email-hans.holmberg@intel.com
State New, archived
Headers show

Commit Message

Hans Holmberg Jan. 9, 2015, 8:40 a.m. UTC
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).

Signed-off-by: Hans Holmberg <hans.holmberg@intel.com>
---
 drivers/gpio/gpiolib-of.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Alexandre Courbot Jan. 14, 2015, 5:39 a.m. UTC | #1
On Fri, Jan 9, 2015 at 5:40 PM, Hans Holmberg <hans.holmberg@intel.com> wrote:
> 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).
>
> Signed-off-by: Hans Holmberg <hans.holmberg@intel.com>
> ---
>  drivers/gpio/gpiolib-of.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 604dbe6..08261f2 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -45,8 +45,14 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
>                 return false;
>
>         ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
> -       if (ret < 0)
> -               return false;
> +       if (ret < 0) {
> +               /* We've found the gpio chip, but the translation failed.
> +                * Return true to stop looking and return the translation
> +                * error via out_gpio
> +                */
> +               gg_data->out_gpio = ERR_PTR(ret);
> +               return true;
> +        }

Nice catch.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
--
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
Linus Walleij Jan. 15, 2015, 5:32 p.m. UTC | #2
On Fri, Jan 9, 2015 at 9:40 AM, Hans Holmberg <hans.holmberg@intel.com> wrote:

> 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).
>
> Signed-off-by: Hans Holmberg <hans.holmberg@intel.com>

Patch applied for fixes with Alex's ACK.

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 mbox

Patch

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 604dbe6..08261f2 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -45,8 +45,14 @@  static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
 		return false;
 
 	ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
-	if (ret < 0)
-		return false;
+	if (ret < 0) {
+		/* We've found the gpio chip, but the translation failed.
+		 * Return true to stop looking and return the translation
+		 * error via out_gpio
+		 */
+		gg_data->out_gpio = ERR_PTR(ret);
+		return true;
+	 }
 
 	gg_data->out_gpio = gpiochip_get_desc(gc, ret);
 	return true;