Documentation: gpio: documentation for optional getters functions
Add a mention about the _optional variants of (devm_)gpiod_get*(). Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
52addcf9d6
commit
1b11a9b9e0
|
@ -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,
|
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
|
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
|
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:
|
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,
|
unsigned int idx,
|
||||||
enum gpiod_flags flags)
|
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:
|
A GPIO descriptor can be disposed of using the gpiod_put() function:
|
||||||
|
|
||||||
void gpiod_put(struct gpio_desc *desc)
|
void gpiod_put(struct gpio_desc *desc)
|
||||||
|
|
Loading…
Reference in New Issue