From: Mathias Nyman Date: Thu, 25 Oct 2012 11:03:03 +0000 (+0300) Subject: gpiolib: Don't return -EPROBE_DEFER to sysfs, or for invalid gpios X-Git-Tag: v3.6.6~21 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=4b4717878e2e70626855d5a6b4639a8e37599acc;p=karo-tx-linux.git gpiolib: Don't return -EPROBE_DEFER to sysfs, or for invalid gpios commit ad2fab36d7922401c4576fb7ea9b21a47a29a17f upstream. gpios requested with invalid numbers, or gpios requested from userspace via sysfs should not try to be deferred on failure. Signed-off-by: Mathias Nyman Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index de0213c9d11c..f03ae68051d6 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -623,9 +623,11 @@ static ssize_t export_store(struct class *class, */ status = gpio_request(gpio, "sysfs"); - if (status < 0) + if (status < 0) { + if (status == -EPROBE_DEFER) + status = -ENODEV; goto done; - + } status = gpio_export(gpio, true); if (status < 0) gpio_free(gpio); @@ -1191,8 +1193,10 @@ int gpio_request(unsigned gpio, const char *label) spin_lock_irqsave(&gpio_lock, flags); - if (!gpio_is_valid(gpio)) + if (!gpio_is_valid(gpio)) { + status = -EINVAL; goto done; + } desc = &gpio_desc[gpio]; chip = desc->chip; if (chip == NULL)