aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2013-07-18 06:19:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 13:40:37 -0400
commit9dabaf5eddbafa21aded7c063cb38d2e8936c237 (patch)
tree2f2d04842bc15b761d48f51603e511f7e2a2b946 /include/linux
parent60b188f0d679656a1a2603d3bc1fa005373f4b9c (diff)
iio: core: implement devm_iio_device_alloc/devm_iio_device_free
Add a resource managed devm_iio_device_alloc()/devm_iio_device_free() to automatically clean up any allocations made by IIO drivers, thus leading to simplified IIO drivers code. In addition, this will allow IIO drivers to use other devm_*() API (like devm_request_irq) and don't care about the race between iio_device_free() and the release of resources by Device core during driver removing. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Tested-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/iio/iio.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 3d35b7023591..61d220f89aca 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -532,6 +532,31 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv)
532void iio_device_free(struct iio_dev *indio_dev); 532void iio_device_free(struct iio_dev *indio_dev);
533 533
534/** 534/**
535 * devm_iio_device_alloc - Resource-managed iio_device_alloc()
536 * @dev: Device to allocate iio_dev for
537 * @sizeof_priv: Space to allocate for private structure.
538 *
539 * Managed iio_device_alloc. iio_dev allocated with this function is
540 * automatically freed on driver detach.
541 *
542 * If an iio_dev allocated with this function needs to be freed separately,
543 * devm_iio_device_free() must be used.
544 *
545 * RETURNS:
546 * Pointer to allocated iio_dev on success, NULL on failure.
547 */
548struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv);
549
550/**
551 * devm_iio_device_free - Resource-managed iio_device_free()
552 * @dev: Device this iio_dev belongs to
553 * @indio_dev: the iio_dev associated with the device
554 *
555 * Free indio_dev allocated with devm_iio_device_alloc().
556 */
557void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev);
558
559/**
535 * iio_buffer_enabled() - helper function to test if the buffer is enabled 560 * iio_buffer_enabled() - helper function to test if the buffer is enabled
536 * @indio_dev: IIO device structure for device 561 * @indio_dev: IIO device structure for device
537 **/ 562 **/