Skip to content

Commit

Permalink
gpiolib: let gpiod_request() return -EPROBE_DEFER
Browse files Browse the repository at this point in the history
Patch be1a4b brought some improvements to the GPIO error handling code,
but also changed the return value of gpiod_request() when called on a
not yet initialized GPIO descriptor: it now returns -EINVAL instead of
-EPROBE_DEFER, and this affects some drivers.

This patch restores the original behavior for gpiod_request(). It is
safe to do so now that desc_to_gpio() does not rely on the GPIO
descriptor to be initialized. Other functions changed by patch be1a4b
do not see their return value affected, so these are not reverted.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reported-by: Dr. H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Alexandre Courbot authored and Linus Walleij committed Oct 11, 2013
1 parent 8c0fca8 commit 0204df4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,14 +1398,16 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
int status = -EPROBE_DEFER;
unsigned long flags;

if (!desc || !desc->chip) {
if (!desc) {
pr_warn("%s: invalid GPIO\n", __func__);
return -EINVAL;
}

spin_lock_irqsave(&gpio_lock, flags);

chip = desc->chip;
if (chip == NULL)
goto done;

if (!try_module_get(chip->owner))
goto done;
Expand Down

0 comments on commit 0204df4

Please sign in to comment.