From 1e9663c62b32f695af37fec4afc473b59f5ca9b4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 25 Mar 2013 08:58:00 +0000 Subject: iio:trigger: Introduce iio_tigger_{set,get}_drvdata Introduce iio_tigger_{set,get}_drvdata which allows to attach driver specific data to a trigger. The functions wrap access to the triggers private_data field and all current users are updated to use iio_tigger_{set,get}_drvdata instead of directly accessing the private_data field. This is the first step towards removing the private_data field from the iio_trigger struct. The following coccinelle script has been used to update the drivers: @@ struct iio_trigger *trigger; expression priv; @@ -trigger->private_data = priv +iio_trigger_set_drv_data(trigger, priv) @@ struct iio_trigger *trigger; @@ -trigger->private_data +iio_trigger_get_drv_data(trigger) Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- include/linux/iio/trigger.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/linux/iio') diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index c66e0a96f6e8..b81948aba1d6 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -91,6 +91,30 @@ static inline void iio_trigger_get(struct iio_trigger *trig) __module_get(trig->ops->owner); } +/** + * iio_device_set_drvdata() - Set trigger driver data + * @trig: IIO trigger structure + * @data: Driver specific data + * + * Allows to attach an arbitrary pointer to an IIO trigger, which can later be + * retrieved by iio_trigger_get_drvdata(). + */ +static inline void iio_trigger_set_drvdata(struct iio_trigger *trig, void *data) +{ + trig->private_data = data; +} + +/** + * iio_trigger_get_drvdata() - Get trigger driver data + * @trig: IIO trigger structure + * + * Returns the data previously set with iio_trigger_set_drvdata() + */ +static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig) +{ + return trig->private_data; +} + /** * iio_trigger_register() - register a trigger with the IIO core * @trig_info: trigger to be registered -- cgit v1.2.3