gpiolib: Defer failed gpio requests by default
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 9 Jul 2012 11:22:56 +0000 (12:22 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 17 Jul 2012 19:00:20 +0000 (21:00 +0200)
Since users must be explicitly provided with a GPIO number in order to
request one the overwhelmingly common case for failing to request will
be that the required GPIO driver has not yet registered and we should
therefore defer until it has registered.

In order to avoid having to code this logic in individual drivers have
gpio_request() return -EPROBE_DEFER when failing to look up the GPIO.
Drivers which don't want this behaviour can override it if they desire.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index 120b2a0e3167fd7a8210fbbb8e86ee336ea7efc5..de0213c9d11ce12e5496d18b49c16ef4ef030d85 100644 (file)
@@ -1186,7 +1186,7 @@ int gpio_request(unsigned gpio, const char *label)
 {
        struct gpio_desc        *desc;
        struct gpio_chip        *chip;
-       int                     status = -EINVAL;
+       int                     status = -EPROBE_DEFER;
        unsigned long           flags;
 
        spin_lock_irqsave(&gpio_lock, flags);