diff options
| -rw-r--r-- | Documentation/gpio/consumer.txt | 24 |
1 files changed, 23 insertions, 1 deletions
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 | |||
| 53 | if and only if no GPIO has been assigned to the device/function/index triplet, | 53 | if and only if no GPIO has been assigned to the device/function/index triplet, |
| 54 | other error codes are used for cases where a GPIO has been assigned but an error | 54 | other error codes are used for cases where a GPIO has been assigned but an error |
| 55 | occurred while trying to acquire it. This is useful to discriminate between mere | 55 | occurred while trying to acquire it. This is useful to discriminate between mere |
| 56 | errors and an absence of GPIO for optional GPIO parameters. | 56 | errors and an absence of GPIO for optional GPIO parameters. For the common |
| 57 | pattern where a GPIO is optional, the gpiod_get_optional() and | ||
| 58 | gpiod_get_index_optional() functions can be used. These functions return NULL | ||
| 59 | instead of -ENOENT if no GPIO has been assigned to the requested function: | ||
| 60 | |||
| 61 | |||
| 62 | struct gpio_desc *gpiod_get_optional(struct device *dev, | ||
| 63 | const char *con_id, | ||
| 64 | enum gpiod_flags flags) | ||
| 65 | |||
| 66 | struct gpio_desc *gpiod_get_index_optional(struct device *dev, | ||
| 67 | const char *con_id, | ||
| 68 | unsigned int index, | ||
| 69 | enum gpiod_flags flags) | ||
| 57 | 70 | ||
| 58 | Device-managed variants of these functions are also defined: | 71 | Device-managed variants of these functions are also defined: |
| 59 | 72 | ||
| @@ -65,6 +78,15 @@ Device-managed variants of these functions are also defined: | |||
| 65 | unsigned int idx, | 78 | unsigned int idx, |
| 66 | enum gpiod_flags flags) | 79 | enum gpiod_flags flags) |
| 67 | 80 | ||
| 81 | struct gpio_desc *devm_gpiod_get_optional(struct device *dev, | ||
| 82 | const char *con_id, | ||
| 83 | enum gpiod_flags flags) | ||
| 84 | |||
| 85 | struct gpio_desc * devm_gpiod_get_index_optional(struct device *dev, | ||
| 86 | const char *con_id, | ||
| 87 | unsigned int index, | ||
| 88 | enum gpiod_flags flags) | ||
| 89 | |||
| 68 | A GPIO descriptor can be disposed of using the gpiod_put() function: | 90 | A GPIO descriptor can be disposed of using the gpiod_put() function: |
| 69 | 91 | ||
| 70 | void gpiod_put(struct gpio_desc *desc) | 92 | void gpiod_put(struct gpio_desc *desc) |
