summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-04-25 17:10:06 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-09-18 08:45:10 +0200
commit8e23cf5068fd4c43d379cf5dd56cd9962aaf3241 (patch)
tree47471d1e5e271028bdfb69f94807a2c6904b58b5 /Documentation
parente9ad022e2f350086fda798bed07128f22e59d7b1 (diff)
gpio: Add helpers for optional GPIOs
Introduce gpiod_get_optional() and gpiod_get_index_optional() helpers that make it easier for drivers to handle optional GPIOs. Currently in order to handle optional GPIOs, a driver needs to special case error handling for -ENOENT, such as this: gpio = gpiod_get(dev, "foo"); if (IS_ERR(gpio)) { if (PTR_ERR(gpio) != -ENOENT) return PTR_ERR(gpio); gpio = NULL; } if (gpio) { /* set up GPIO */ } With these new helpers the above is reduced to: gpio = gpiod_get_optional(dev, "foo"); if (IS_ERR(gpio)) return PTR_ERR(gpio); if (gpio) { /* set up GPIO */ } While at it, device-managed variants of these functions are also provided. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 29a1f2333e07bbbecb920cc78fd035fe8f53207a)
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/driver-model/devres.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 4f7897e99cba..10b8c5d2c797 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -308,3 +308,10 @@ SLAVE DMA ENGINE
SPI
devm_spi_register_master()
+
+GPIO
+ devm_gpiod_get()
+ devm_gpiod_get_index()
+ devm_gpiod_get_optional()
+ devm_gpiod_get_index_optional()
+ devm_gpiod_put()