summaryrefslogtreecommitdiff
path: root/include/linux/iio/iio.h
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-06-04 12:50:02 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-05 08:21:29 +0400
commite4e8b7765867e8f4705bcc18b8930edbe0e4ef3c (patch)
treed908c7a41b1b0f6917007eb4e4621a041905301a /include/linux/iio/iio.h
parent44dd5b02530a5aaea16c1a0a9eea377407445b4a (diff)
downloadlinux-e4e8b7765867e8f4705bcc18b8930edbe0e4ef3c.tar.xz
iio: Add iio_device_get()
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>
Diffstat (limited to 'include/linux/iio/iio.h')
-rw-r--r--include/linux/iio/iio.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 3a4f6a3ab80d..3238fa3374f7 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -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
/**