Lines Matching +full:a +full:- +full:gpio
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * devres.c - managed gpio resources
11 #include <linux/gpio.h>
12 #include <linux/gpio/consumer.h>
27 struct gpio_desc **this = res, **gpio = data; in devm_gpiod_match() local
29 return *this == *gpio; in devm_gpiod_match()
47 * devm_gpiod_get - Resource-managed gpiod_get()
48 * @dev: GPIO consumer
49 * @con_id: function within the GPIO consumer
50 * @flags: optional GPIO initialization flags
52 * Managed gpiod_get(). GPIO descriptors returned from this function are
65 * devm_gpiod_get_optional - Resource-managed gpiod_get_optional()
66 * @dev: GPIO consumer
67 * @con_id: function within the GPIO consumer
68 * @flags: optional GPIO initialization flags
70 * Managed gpiod_get_optional(). GPIO descriptors returned from this function
83 * devm_gpiod_get_index - Resource-managed gpiod_get_index()
84 * @dev: GPIO consumer
85 * @con_id: function within the GPIO consumer
86 * @idx: index of the GPIO to obtain in the consumer
87 * @flags: optional GPIO initialization flags
89 * Managed gpiod_get_index(). GPIO descriptors returned from this function are
106 * For non-exclusive GPIO descriptors, check if this descriptor is in devm_gpiod_get_index()
122 return ERR_PTR(-ENOMEM); in devm_gpiod_get_index()
133 * devm_gpiod_get_from_of_node() - obtain a GPIO from an OF node
136 * @propname: name of the DT property representing the GPIO
137 * @index: index of the GPIO to obtain for the consumer
138 * @dflags: GPIO initialization flags
139 * @label: label to attach to the requested GPIO
142 * On successful request the GPIO pin is configured in accordance with
161 * For non-exclusive GPIO descriptors, check if this descriptor is in devm_gpiod_get_from_of_node()
177 return ERR_PTR(-ENOMEM); in devm_gpiod_get_from_of_node()
188 * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node
189 * @dev: GPIO consumer
190 * @fwnode: firmware node containing GPIO reference
191 * @con_id: function within the GPIO consumer
192 * @index: index of the GPIO to obtain in the consumer
193 * @flags: GPIO initialization flags
194 * @label: label to attach to the requested GPIO
196 * GPIO descriptors returned from this function are automatically disposed on
199 * On successful request the GPIO pin is configured in accordance with
214 return ERR_PTR(-ENOMEM); in devm_fwnode_gpiod_get_index()
230 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
231 * @dev: GPIO consumer
232 * @con_id: function within the GPIO consumer
233 * @index: index of the GPIO to obtain in the consumer
234 * @flags: optional GPIO initialization flags
236 * Managed gpiod_get_index_optional(). GPIO descriptors returned from this
250 if (PTR_ERR(desc) == -ENOENT) in devm_gpiod_get_index_optional()
259 * devm_gpiod_get_array - Resource-managed gpiod_get_array()
260 * @dev: GPIO consumer
261 * @con_id: function within the GPIO consumer
262 * @flags: optional GPIO initialization flags
264 * Managed gpiod_get_array(). GPIO descriptors returned from this function are
278 return ERR_PTR(-ENOMEM); in devm_gpiod_get_array()
294 * devm_gpiod_get_array_optional - Resource-managed gpiod_get_array_optional()
295 * @dev: GPIO consumer
296 * @con_id: function within the GPIO consumer
297 * @flags: optional GPIO initialization flags
299 * Managed gpiod_get_array_optional(). GPIO descriptors returned from this
311 if (PTR_ERR(descs) == -ENOENT) in devm_gpiod_get_array_optional()
319 * devm_gpiod_put - Resource-managed gpiod_put()
320 * @dev: GPIO consumer
321 * @desc: GPIO descriptor to dispose of
323 * Dispose of a GPIO descriptor obtained with devm_gpiod_get() or
324 * devm_gpiod_get_index(). Normally this function will not be called as the GPIO
335 * devm_gpiod_unhinge - Remove resource management from a gpio descriptor
336 * @dev: GPIO consumer
337 * @desc: GPIO descriptor to remove resource management from
339 * Remove resource management from a GPIO descriptor. This is needed when
340 * you want to hand over lifecycle management of a descriptor to another
353 * If the GPIO descriptor is requested as nonexclusive, we in devm_gpiod_unhinge()
355 * so it is OK if devres_destroy() returns -ENOENT. in devm_gpiod_unhinge()
357 if (ret == -ENOENT) in devm_gpiod_unhinge()
365 * devm_gpiod_put_array - Resource-managed gpiod_put_array()
366 * @dev: GPIO consumer
367 * @descs: GPIO descriptor array to dispose of
369 * Dispose of an array of GPIO descriptors obtained with devm_gpiod_get_array().
385 unsigned *gpio = res; in devm_gpio_release() local
387 gpio_free(*gpio); in devm_gpio_release()
392 unsigned *this = res, *gpio = data; in devm_gpio_match() local
394 return *this == *gpio; in devm_gpio_match()
398 * devm_gpio_request - request a GPIO for a managed device
399 * @dev: device to request the GPIO for
400 * @gpio: GPIO to allocate
401 * @label: the name of the requested GPIO
408 * If an GPIO allocated with this function needs to be freed
412 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label) in devm_gpio_request() argument
419 return -ENOMEM; in devm_gpio_request()
421 rc = gpio_request(gpio, label); in devm_gpio_request()
427 *dr = gpio; in devm_gpio_request()
435 * devm_gpio_request_one - request a single GPIO with initial setup
437 * @gpio: the GPIO number
438 * @flags: GPIO configuration as specified by GPIOF_*
439 * @label: a literal description string of this GPIO
441 int devm_gpio_request_one(struct device *dev, unsigned gpio, in devm_gpio_request_one() argument
449 return -ENOMEM; in devm_gpio_request_one()
451 rc = gpio_request_one(gpio, flags, label); in devm_gpio_request_one()
457 *dr = gpio; in devm_gpio_request_one()
465 * devm_gpio_free - free a GPIO
466 * @dev: device to free GPIO for
467 * @gpio: GPIO to free
474 void devm_gpio_free(struct device *dev, unsigned int gpio) in devm_gpio_free() argument
478 &gpio)); in devm_gpio_free()
490 * devm_gpiochip_add_data_with_key() - Resource managed gpiochip_add_data_with_key()
492 * @gc: the GPIO chip to register
493 * @data: driver-private data associated with this chip
499 * The gpio chip automatically be released when the device is unbound.
502 * A negative errno if the chip can't be registered, such as because the
503 * gc->base is invalid or already associated with a different chip.
504 * Otherwise it returns zero as a success code.
516 return -ENOMEM; in devm_gpiochip_add_data_with_key()