]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
iio: Add iio_device_get()
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 4 Jun 2012 08:50:02 +0000 (10:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Jun 2012 04:21:29 +0000 (21:21 -0700)
This patch add the iio_device_get() function, which increases the reference
count of a iio device. The matching function to decrease the reference count -
iio_device_put() - already exists.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/iio/iio.h

index 3a4f6a3ab80d51cd1ecbd550fd831b1551f9136d..3238fa3374f728d3ee9d3f4eac0834b6907af8dc 100644 (file)
@@ -438,6 +438,17 @@ static inline struct iio_dev *dev_to_iio_dev(struct device *dev)
        return container_of(dev, struct iio_dev, dev);
 }
 
+/**
+ * iio_device_get() - increment reference count for the device
+ * @indio_dev: IIO device structure
+ *
+ * Returns: The passed IIO device
+ **/
+static inline struct iio_dev *iio_device_get(struct iio_dev *indio_dev)
+{
+       return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL;
+}
+
 /* Can we make this smaller? */
 #define IIO_ALIGN L1_CACHE_BYTES
 /**