* [PATCH] Documentation: gpio: documentation for optional getters functions
@ 2014-08-18 16:39 Alexandre Courbot
2014-08-29 6:54 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Courbot @ 2014-08-18 16:39 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-doc, linux-kernel, Alexandre Courbot
Add a mention about the _optional variants of (devm_)gpiod_get*().
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Documentation/gpio/consumer.txt | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index 76546324e968..6ce544191ca6 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -53,7 +53,20 @@ with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned
if and only if no GPIO has been assigned to the device/function/index triplet,
other error codes are used for cases where a GPIO has been assigned but an error
occurred while trying to acquire it. This is useful to discriminate between mere
-errors and an absence of GPIO for optional GPIO parameters.
+errors and an absence of GPIO for optional GPIO parameters. For the common
+pattern where a GPIO is optional, the gpiod_get_optional() and
+gpiod_get_index_optional() functions can be used. These functions return NULL
+instead of -ENOENT if no GPIO has been assigned to the requested function:
+
+
+ struct gpio_desc *gpiod_get_optional(struct device *dev,
+ const char *con_id,
+ enum gpiod_flags flags)
+
+ struct gpio_desc *gpiod_get_index_optional(struct device *dev,
+ const char *con_id,
+ unsigned int index,
+ enum gpiod_flags flags)
Device-managed variants of these functions are also defined:
@@ -65,6 +78,15 @@ Device-managed variants of these functions are also defined:
unsigned int idx,
enum gpiod_flags flags)
+ struct gpio_desc *devm_gpiod_get_optional(struct device *dev,
+ const char *con_id,
+ enum gpiod_flags flags)
+
+ struct gpio_desc * devm_gpiod_get_index_optional(struct device *dev,
+ const char *con_id,
+ unsigned int index,
+ enum gpiod_flags flags)
+
A GPIO descriptor can be disposed of using the gpiod_put() function:
void gpiod_put(struct gpio_desc *desc)
--
2.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Documentation: gpio: documentation for optional getters functions
2014-08-18 16:39 [PATCH] Documentation: gpio: documentation for optional getters functions Alexandre Courbot
@ 2014-08-29 6:54 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2014-08-29 6:54 UTC (permalink / raw)
To: Alexandre Courbot
Cc: linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
On Mon, Aug 18, 2014 at 6:39 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> Add a mention about the _optional variants of (devm_)gpiod_get*().
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Patch applied for fixes.
Yours,
LInus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-29 6:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18 16:39 [PATCH] Documentation: gpio: documentation for optional getters functions Alexandre Courbot
2014-08-29 6:54 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).