diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2014-12-02 23:15:05 +0900 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-12-02 15:46:36 +0100 |
commit | 0e9a5edf5d01356fa4a561772a25d97b3fd13de6 (patch) | |
tree | fc38446b2de4c5edd95f69df5d770cd48779a2d6 /drivers/gpio/gpiolib.c | |
parent | 834296a3c66257616d14aef245dbe86111b5ef6b (diff) | |
download | linux-0e9a5edf5d01356fa4a561772a25d97b3fd13de6.tar.gz linux-0e9a5edf5d01356fa4a561772a25d97b3fd13de6.tar.bz2 linux-0e9a5edf5d01356fa4a561772a25d97b3fd13de6.zip |
gpio: fix deferred probe detection for legacy API
Commit 14e85c0e69d5 ("gpio: remove gpio_descs global array") changed
gpio_to_desc()'s behavior to return NULL not only for GPIOs numbers
not in the valid range, but also for all GPIOs whose controller has not
been probed yet. Although this behavior is more correct (nothing hints
that these GPIO numbers will be populated later), this affects
gpio_request() and gpio_request_one() which call gpiod_request() with a
NULL descriptor, causing it to return -EINVAL instead of the expected
-EPROBE_DEFER for a non-probed GPIO.
gpiod_request() is only called with a descriptor obtained from
gpio_to_desc() from these two functions, so address the issue there.
Other ways to obtain GPIOs rely on well-defined mappings and can thus
return -EPROBE_DEFER only for relevant GPIOs, and are thus not affected
by this issue.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0b271ef87c09..56b7c5de95a0 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -77,7 +77,9 @@ struct gpio_desc *gpio_to_desc(unsigned gpio) spin_unlock_irqrestore(&gpio_lock, flags); - WARN(1, "invalid GPIO %d\n", gpio); + if (!gpio_is_valid(gpio)) + WARN(1, "invalid GPIO %d\n", gpio); + return NULL; } EXPORT_SYMBOL_GPL(gpio_to_desc); |