aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/gpio
diff options
context:
space:
mode:
authorRojhalat Ibrahim <imr@rtschenk.de>2015-02-11 11:27:58 -0500
committerLinus Walleij <linus.walleij@linaro.org>2015-03-05 03:52:28 -0500
commit668585273246f67b0cdafa30dd2da2047a2e1290 (patch)
treec6e3186d6aab7d08e0f50b5030be4bef4a8b17df /Documentation/gpio
parent7f2e553a7173b485db41a52060f91fb8e5ab1c69 (diff)
gpiolib: add gpiod_get_array and gpiod_put_array functions
Introduce new functions for conveniently obtaining and disposing of an entire array of GPIOs with one function call. ACPI parts tested by Mika Westerberg, DT parts tested by Rojhalat Ibrahim. Change log: v5: move the ACPI functions to gpiolib-acpi.c v4: - use shorter names for members of struct gpio_descs - rename lut_gpio_count to platform_gpio_count for clarity - add check for successful memory allocation - use ERR_CAST() v3: - rebase on current linux-gpio devel branch - fix ACPI GPIO counting - allow for zero-sized arrays - make the flags argument mandatory for the new functions - clarify documentation v2: change interface Suggested-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Rojhalat Ibrahim <imr@rtschenk.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/gpio')
-rw-r--r--Documentation/gpio/consumer.txt33
1 files changed, 30 insertions, 3 deletions
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index d85fbae451ea..2924f2ffcd91 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -58,7 +58,6 @@ pattern where a GPIO is optional, the gpiod_get_optional() and
58gpiod_get_index_optional() functions can be used. These functions return NULL 58gpiod_get_index_optional() functions can be used. These functions return NULL
59instead of -ENOENT if no GPIO has been assigned to the requested function: 59instead of -ENOENT if no GPIO has been assigned to the requested function:
60 60
61
62 struct gpio_desc *gpiod_get_optional(struct device *dev, 61 struct gpio_desc *gpiod_get_optional(struct device *dev,
63 const char *con_id, 62 const char *con_id,
64 enum gpiod_flags flags) 63 enum gpiod_flags flags)
@@ -68,6 +67,27 @@ instead of -ENOENT if no GPIO has been assigned to the requested function:
68 unsigned int index, 67 unsigned int index,
69 enum gpiod_flags flags) 68 enum gpiod_flags flags)
70 69
70For a function using multiple GPIOs all of those can be obtained with one call:
71
72 struct gpio_descs *gpiod_get_array(struct device *dev,
73 const char *con_id,
74 enum gpiod_flags flags)
75
76This function returns a struct gpio_descs which contains an array of
77descriptors:
78
79 struct gpio_descs {
80 unsigned int ndescs;
81 struct gpio_desc *desc[];
82 }
83
84The following function returns NULL instead of -ENOENT if no GPIOs have been
85assigned to the requested function:
86
87 struct gpio_descs *gpiod_get_array_optional(struct device *dev,
88 const char *con_id,
89 enum gpiod_flags flags)
90
71Device-managed variants of these functions are also defined: 91Device-managed variants of these functions are also defined:
72 92
73 struct gpio_desc *devm_gpiod_get(struct device *dev, const char *con_id, 93 struct gpio_desc *devm_gpiod_get(struct device *dev, const char *con_id,
@@ -91,8 +111,15 @@ A GPIO descriptor can be disposed of using the gpiod_put() function:
91 111
92 void gpiod_put(struct gpio_desc *desc) 112 void gpiod_put(struct gpio_desc *desc)
93 113
94It is strictly forbidden to use a descriptor after calling this function. The 114For an array of GPIOs this function can be used:
95device-managed variant is, unsurprisingly: 115
116 void gpiod_put_array(struct gpio_descs *descs)
117
118It is strictly forbidden to use a descriptor after calling these functions.
119It is also not allowed to individually release descriptors (using gpiod_put())
120from an array acquired with gpiod_get_array().
121
122The device-managed variant is, unsurprisingly:
96 123
97 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) 124 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc)
98 125