aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-05-12 09:39:32 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-14 16:34:31 -0400
commit7a7913f11ddf932e20d2bde72bec57f2f7a9b49e (patch)
tree8494f244143cae26b4b470aeee59209323ccb0d0 /include/linux
parent7086e6e5baae90047ecfb1416082409634868e66 (diff)
iio: Add dev_to_iio_dev() helper function
This patch adds a helper function for retriving a iio_dev struct from a device struct. Currently we open-code this in two different ways. One is using dev_get_drvdata on the device and the other is using container_of. The new helper function uses the container_of solution as it creates slightly smaller code and also will eventually free up the drvdata pointer for usage by invidual drivers. 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')
-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)
427 put_device(&indio_dev->dev); 427 put_device(&indio_dev->dev);
428}; 428};
429 429
430/**
431 * dev_to_iio_dev() - Get IIO device struct from a device struct
432 * @dev: The device embedded in the IIO device
433 *
434 * Note: The device must be a IIO device, otherwise the result is undefined.
435 */
436static inline struct iio_dev *dev_to_iio_dev(struct device *dev)
437{
438 return container_of(dev, struct iio_dev, dev);
439}
440
430/* Can we make this smaller? */ 441/* Can we make this smaller? */
431#define IIO_ALIGN L1_CACHE_BYTES 442#define IIO_ALIGN L1_CACHE_BYTES
432/** 443/**