summaryrefslogtreecommitdiff
path: root/include/linux/iio
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/iio')
-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 897c6b01d784..3a4f6a3ab80d 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -427,6 +427,17 @@ static inline void iio_device_put(struct iio_dev *indio_dev)
put_device(&indio_dev->dev);
};
+/**
+ * dev_to_iio_dev() - Get IIO device struct from a device struct
+ * @dev: The device embedded in the IIO device
+ *
+ * Note: The device must be a IIO device, otherwise the result is undefined.
+ */
+static inline struct iio_dev *dev_to_iio_dev(struct device *dev)
+{
+ return container_of(dev, struct iio_dev, dev);
+}
+
/* Can we make this smaller? */
#define IIO_ALIGN L1_CACHE_BYTES
/**