aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-08-10 12:36:00 -0400
committerJonathan Cameron <jic23@kernel.org>2012-08-27 12:52:26 -0400
commit2d66f389ccf2c3ffea93c0270ef34186e4995333 (patch)
tree6942c3c11162169838ea0021b5cad8e4961715e0
parent49f8812e4d15970341f0ed320e78951cc16b596d (diff)
iio: Introduce iio_device_{set,get}_drvdata()
Introduce two new helper functions to attach a arbitrary pointer to a IIO device. This is useful to get access to external non-global data from within a IIO device callbacks where only the IIO device is available. Internally these functions use dev_{set,get}_drvdata() on the struct device embedded in the IIO device. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-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 be82936c4089..b18e74e0bdd5 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -516,6 +516,31 @@ static inline struct iio_dev *iio_device_get(struct iio_dev *indio_dev)
516 return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL; 516 return indio_dev ? dev_to_iio_dev(get_device(&indio_dev->dev)) : NULL;
517} 517}
518 518
519
520/**
521 * iio_device_set_drvdata() - Set device driver data
522 * @indio_dev: IIO device structure
523 * @data: Driver specific data
524 *
525 * Allows to attach an arbitrary pointer to an IIO device, which can later be
526 * retrieved by iio_device_get_drvdata().
527 */
528static inline void iio_device_set_drvdata(struct iio_dev *indio_dev, void *data)
529{
530 dev_set_drvdata(&indio_dev->dev, data);
531}
532
533/**
534 * iio_device_get_drvdata() - Get device driver data
535 * @indio_dev: IIO device structure
536 *
537 * Returns the data previously set with iio_device_set_drvdata()
538 */
539static inline void *iio_device_get_drvdata(struct iio_dev *indio_dev)
540{
541 return dev_get_drvdata(&indio_dev->dev);
542}
543
519/* Can we make this smaller? */ 544/* Can we make this smaller? */
520#define IIO_ALIGN L1_CACHE_BYTES 545#define IIO_ALIGN L1_CACHE_BYTES
521/** 546/**