aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio
diff options
context:
space:
mode:
authorRojhalat Ibrahim <imr@rtschenk.de>2015-02-11 11:28:02 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-03-05 03:55:42 -0500
commit331758eef83620eef3f21289f0f44aba094d0503 (patch)
tree45b24f0b201b6b05333ebcf433a80a41454f6e73 /include/linux/gpio
parent668585273246f67b0cdafa30dd2da2047a2e1290 (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.h30
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,
83struct gpio_desc *__must_check 83struct 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);
86struct gpio_descs *__must_check devm_gpiod_get_array(struct device *dev,
87 const char *con_id,
88 enum gpiod_flags flags);
89struct gpio_descs *__must_check
90devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
91 enum gpiod_flags flags);
86void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); 92void devm_gpiod_put(struct device *dev, struct gpio_desc *desc);
93void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs);
87 94
88int gpiod_get_direction(struct gpio_desc *desc); 95int gpiod_get_direction(struct gpio_desc *desc);
89int gpiod_direction_input(struct gpio_desc *desc); 96int 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
238static inline struct gpio_descs *__must_check
239devm_gpiod_get_array(struct device *dev, const char *con_id,
240 enum gpiod_flags flags)
241{
242 return ERR_PTR(-ENOSYS);
243}
244
245static inline struct gpio_descs *__must_check
246devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
247 enum gpiod_flags flags)
248{
249 return ERR_PTR(-ENOSYS);
250}
251
231static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) 252static 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
260static 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
240static inline int gpiod_get_direction(const struct gpio_desc *desc) 270static inline int gpiod_get_direction(const struct gpio_desc *desc)
241{ 271{