diff options
| author | Rojhalat Ibrahim <imr@rtschenk.de> | 2015-02-11 11:28:02 -0500 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2015-03-05 03:55:42 -0500 |
| commit | 331758eef83620eef3f21289f0f44aba094d0503 (patch) | |
| tree | 45b24f0b201b6b05333ebcf433a80a41454f6e73 /include/linux/gpio | |
| parent | 668585273246f67b0cdafa30dd2da2047a2e1290 (diff) | |
gpiolib: add devm_gpiod_get_array and devm_gpiod_put_array functions
Add device managed variants of gpiod_get_array() / gpiod_put_array()
functions for conveniently obtaining and disposing of an entire array
of GPIOs with one function call.
Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio')
| -rw-r--r-- | include/linux/gpio/consumer.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 33eb52fd0932..3a7c9ffd5ab9 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
| @@ -83,7 +83,14 @@ struct gpio_desc *__must_check __devm_gpiod_get_optional(struct device *dev, | |||
| 83 | struct gpio_desc *__must_check | 83 | struct gpio_desc *__must_check |
| 84 | __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, | 84 | __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, |
| 85 | unsigned int index, enum gpiod_flags flags); | 85 | unsigned int index, enum gpiod_flags flags); |
| 86 | struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev, | ||
| 87 | const char *con_id, | ||
| 88 | enum gpiod_flags flags); | ||
| 89 | struct gpio_descs *__must_check | ||
| 90 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, | ||
| 91 | enum gpiod_flags flags); | ||
| 86 | void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); | 92 | void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); |
| 93 | void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs); | ||
| 87 | 94 | ||
| 88 | int gpiod_get_direction(struct gpio_desc *desc); | 95 | int gpiod_get_direction(struct gpio_desc *desc); |
| 89 | int gpiod_direction_input(struct gpio_desc *desc); | 96 | int gpiod_direction_input(struct gpio_desc *desc); |
| @@ -228,6 +235,20 @@ __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, | |||
| 228 | return ERR_PTR(-ENOSYS); | 235 | return ERR_PTR(-ENOSYS); |
| 229 | } | 236 | } |
| 230 | 237 | ||
| 238 | static inline struct gpio_descs *__must_check | ||
| 239 | devm_gpiod_get_array(struct device *dev, const char *con_id, | ||
| 240 | enum gpiod_flags flags) | ||
| 241 | { | ||
| 242 | return ERR_PTR(-ENOSYS); | ||
| 243 | } | ||
| 244 | |||
| 245 | static inline struct gpio_descs *__must_check | ||
| 246 | devm_gpiod_get_array_optional(struct device *dev, const char *con_id, | ||
| 247 | enum gpiod_flags flags) | ||
| 248 | { | ||
| 249 | return ERR_PTR(-ENOSYS); | ||
| 250 | } | ||
| 251 | |||
| 231 | static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) | 252 | static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) |
| 232 | { | 253 | { |
| 233 | might_sleep(); | 254 | might_sleep(); |
| @@ -236,6 +257,15 @@ static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) | |||
| 236 | WARN_ON(1); | 257 | WARN_ON(1); |
| 237 | } | 258 | } |
| 238 | 259 | ||
| 260 | static inline void devm_gpiod_put_array(struct device *dev, | ||
| 261 | struct gpio_descs *descs) | ||
| 262 | { | ||
| 263 | might_sleep(); | ||
| 264 | |||
| 265 | /* GPIO can never have been requested */ | ||
| 266 | WARN_ON(1); | ||
| 267 | } | ||
| 268 | |||
| 239 | 269 | ||
| 240 | static inline int gpiod_get_direction(const struct gpio_desc *desc) | 270 | static inline int gpiod_get_direction(const struct gpio_desc *desc) |
| 241 | { | 271 | { |
