diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-02-12 17:13:55 -0800 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-03-15 11:16:30 +0100 |
commit | 22c403676dbbb7c6f186099527af7f065498ef45 (patch) | |
tree | b4c165eee3ec51b83a17bd1d62f5e0851d28287c /Documentation/gpio | |
parent | 85c73d50e57eb8ad43955fe38714bc5fba1acd92 (diff) |
gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled
Given the intent behind gpiod_get_optional() and friends it does not make
sense to return -ENOSYS when GPIOLIB is disabled: the driver is expected to
work just fine without gpio so let's behave as if gpio was not found.
Otherwise we have to special-case -ENOSYS in drivers.
Note that there was objection that someone might forget to enable GPIOLIB
when dealing with a platform that has device that actually specifies
optional gpio and we'll break it. I find this unconvincing as that would
have to be the *only GPIO* in the system, which is extremely unlikely.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/gpio')
-rw-r--r-- | Documentation/gpio/consumer.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt index 05676fdacfe3..912568baabb9 100644 --- a/Documentation/gpio/consumer.txt +++ b/Documentation/gpio/consumer.txt @@ -70,6 +70,12 @@ instead of -ENOENT if no GPIO has been assigned to the requested function: unsigned int index, enum gpiod_flags flags) +Note that gpio_get*_optional() functions (and their managed variants), unlike +the rest of gpiolib API, also return NULL when gpiolib support is disabled. +This is helpful to driver authors, since they do not need to special case +-ENOSYS return codes. System integrators should however be careful to enable +gpiolib on systems that need it. + For a function using multiple GPIOs all of those can be obtained with one call: struct gpio_descs *gpiod_get_array(struct device *dev, |