gpio: improve error path in gpiolib
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 30 Aug 2013 07:41:45 +0000 (09:41 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 3 Sep 2013 12:08:28 +0000 (14:08 +0200)
commitbe1a4b13089b1e18da83a549d49163ccad3c19ba
tree321f0e432ef3df8f7ea17a664087e58d3f24a7c6
parent6c17aa0138a6c55364936bbaa35846e09a4db53b
gpio: improve error path in gpiolib

At several places the gpiolib will proceed to handle a GPIO
descriptor even if it's ->chip member is NULL and no gpiochip
is associated.

Fix this by checking that both the descriptor cookie *and*
the chip pointer are valid.

Also bail out earlier with more specific diagnostic messages
on missing operations for setting as input/output or debounce.

ChangeLog v1->v2:
- Also return -EIO on gpiod_set_debounce() with missing
  operations in the vtable
- Fix indentations.

Suggested-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Frank Rowand <frank.rowand@sonymobile.com>
Cc: Tim Bird <tim.bird@sonymobile.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c