diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-03-25 04:58:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-03-25 17:06:09 -0400 |
commit | 1e9663c62b32f695af37fec4afc473b59f5ca9b4 (patch) | |
tree | 8f1c1c9fbaa89c3f75ad14a04dd8ee20ecb6dba0 /drivers/iio | |
parent | c5cf4606b6659e711258b6e567415ab83a3b646c (diff) |
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:
<smpl>
@@
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)
</smpl>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/st_accel_buffer.c | 2 | ||||
-rw-r--r-- | drivers/iio/adc/ad_sigma_delta.c | 2 | ||||
-rw-r--r-- | drivers/iio/adc/at91_adc.c | 4 | ||||
-rw-r--r-- | drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 4 | ||||
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_trigger.c | 2 | ||||
-rw-r--r-- | drivers/iio/gyro/itg3200_buffer.c | 4 | ||||
-rw-r--r-- | drivers/iio/gyro/st_gyro_buffer.c | 2 | ||||
-rw-r--r-- | drivers/iio/imu/adis_trigger.c | 4 | ||||
-rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 4 |
9 files changed, 14 insertions, 14 deletions
diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c index 6bd82c7f769c..d9b350756f90 100644 --- a/drivers/iio/accel/st_accel_buffer.c +++ b/drivers/iio/accel/st_accel_buffer.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | int st_accel_trig_set_state(struct iio_trigger *trig, bool state) | 26 | int st_accel_trig_set_state(struct iio_trigger *trig, bool state) |
27 | { | 27 | { |
28 | struct iio_dev *indio_dev = trig->private_data; | 28 | struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); |
29 | 29 | ||
30 | return st_sensors_set_dataready_irq(indio_dev, state); | 30 | return st_sensors_set_dataready_irq(indio_dev, state); |
31 | } | 31 | } |
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index afe6d78c8ff0..f0d6335ae087 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c | |||
@@ -470,7 +470,7 @@ static int ad_sd_probe_trigger(struct iio_dev *indio_dev) | |||
470 | disable_irq_nosync(sigma_delta->spi->irq); | 470 | disable_irq_nosync(sigma_delta->spi->irq); |
471 | } | 471 | } |
472 | sigma_delta->trig->dev.parent = &sigma_delta->spi->dev; | 472 | sigma_delta->trig->dev.parent = &sigma_delta->spi->dev; |
473 | sigma_delta->trig->private_data = sigma_delta; | 473 | iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta); |
474 | 474 | ||
475 | ret = iio_trigger_register(sigma_delta->trig); | 475 | ret = iio_trigger_register(sigma_delta->trig); |
476 | if (ret) | 476 | if (ret) |
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 92eb6a5b9e72..6fc43c15f028 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
@@ -188,7 +188,7 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev, | |||
188 | 188 | ||
189 | static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) | 189 | static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) |
190 | { | 190 | { |
191 | struct iio_dev *idev = trig->private_data; | 191 | struct iio_dev *idev = iio_trigger_get_drvdata(trig); |
192 | struct at91_adc_state *st = iio_priv(idev); | 192 | struct at91_adc_state *st = iio_priv(idev); |
193 | struct iio_buffer *buffer = idev->buffer; | 193 | struct iio_buffer *buffer = idev->buffer; |
194 | struct at91_adc_reg_desc *reg = st->registers; | 194 | struct at91_adc_reg_desc *reg = st->registers; |
@@ -254,7 +254,7 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev, | |||
254 | return NULL; | 254 | return NULL; |
255 | 255 | ||
256 | trig->dev.parent = idev->dev.parent; | 256 | trig->dev.parent = idev->dev.parent; |
257 | trig->private_data = idev; | 257 | iio_trigger_set_drvdata(trig, idev); |
258 | trig->ops = &at91_adc_trigger_ops; | 258 | trig->ops = &at91_adc_trigger_ops; |
259 | 259 | ||
260 | ret = iio_trigger_register(trig); | 260 | ret = iio_trigger_register(trig); |
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 7a525a91105d..87419c41b991 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c | |||
@@ -31,7 +31,7 @@ | |||
31 | static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, | 31 | static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, |
32 | bool state) | 32 | bool state) |
33 | { | 33 | { |
34 | struct hid_sensor_common *st = trig->private_data; | 34 | struct hid_sensor_common *st = iio_trigger_get_drvdata(trig); |
35 | int state_val; | 35 | int state_val; |
36 | 36 | ||
37 | state_val = state ? 1 : 0; | 37 | state_val = state ? 1 : 0; |
@@ -76,7 +76,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, | |||
76 | } | 76 | } |
77 | 77 | ||
78 | trig->dev.parent = indio_dev->dev.parent; | 78 | trig->dev.parent = indio_dev->dev.parent; |
79 | trig->private_data = attrb; | 79 | iio_trigger_set_drvdata(trig, attrb); |
80 | trig->ops = &hid_sensor_trigger_ops; | 80 | trig->ops = &hid_sensor_trigger_ops; |
81 | ret = iio_trigger_register(trig); | 81 | ret = iio_trigger_register(trig); |
82 | 82 | ||
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index 139ed030abb0..8fc3a97eb266 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c | |||
@@ -40,7 +40,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, | |||
40 | if (err) | 40 | if (err) |
41 | goto request_irq_error; | 41 | goto request_irq_error; |
42 | 42 | ||
43 | sdata->trig->private_data = indio_dev; | 43 | iio_trigger_set_drvdata(sdata->trig, indio_dev); |
44 | sdata->trig->ops = trigger_ops; | 44 | sdata->trig->ops = trigger_ops; |
45 | sdata->trig->dev.parent = sdata->dev; | 45 | sdata->trig->dev.parent = sdata->dev; |
46 | 46 | ||
diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c index f667d2c8c00f..6c43af9bb0a4 100644 --- a/drivers/iio/gyro/itg3200_buffer.c +++ b/drivers/iio/gyro/itg3200_buffer.c | |||
@@ -81,7 +81,7 @@ void itg3200_buffer_unconfigure(struct iio_dev *indio_dev) | |||
81 | static int itg3200_data_rdy_trigger_set_state(struct iio_trigger *trig, | 81 | static int itg3200_data_rdy_trigger_set_state(struct iio_trigger *trig, |
82 | bool state) | 82 | bool state) |
83 | { | 83 | { |
84 | struct iio_dev *indio_dev = trig->private_data; | 84 | struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); |
85 | int ret; | 85 | int ret; |
86 | u8 msc; | 86 | u8 msc; |
87 | 87 | ||
@@ -129,7 +129,7 @@ int itg3200_probe_trigger(struct iio_dev *indio_dev) | |||
129 | 129 | ||
130 | st->trig->dev.parent = &st->i2c->dev; | 130 | st->trig->dev.parent = &st->i2c->dev; |
131 | st->trig->ops = &itg3200_trigger_ops; | 131 | st->trig->ops = &itg3200_trigger_ops; |
132 | st->trig->private_data = indio_dev; | 132 | iio_trigger_set_drvdata(st->trig, indio_dev); |
133 | ret = iio_trigger_register(st->trig); | 133 | ret = iio_trigger_register(st->trig); |
134 | if (ret) | 134 | if (ret) |
135 | goto error_free_irq; | 135 | goto error_free_irq; |
diff --git a/drivers/iio/gyro/st_gyro_buffer.c b/drivers/iio/gyro/st_gyro_buffer.c index da4d122ec7dc..69017c7ec302 100644 --- a/drivers/iio/gyro/st_gyro_buffer.c +++ b/drivers/iio/gyro/st_gyro_buffer.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | int st_gyro_trig_set_state(struct iio_trigger *trig, bool state) | 26 | int st_gyro_trig_set_state(struct iio_trigger *trig, bool state) |
27 | { | 27 | { |
28 | struct iio_dev *indio_dev = trig->private_data; | 28 | struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); |
29 | 29 | ||
30 | return st_sensors_set_dataready_irq(indio_dev, state); | 30 | return st_sensors_set_dataready_irq(indio_dev, state); |
31 | } | 31 | } |
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c index 5a24c9cac343..e0017c22bb9c 100644 --- a/drivers/iio/imu/adis_trigger.c +++ b/drivers/iio/imu/adis_trigger.c | |||
@@ -19,7 +19,7 @@ | |||
19 | static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, | 19 | static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, |
20 | bool state) | 20 | bool state) |
21 | { | 21 | { |
22 | struct adis *adis = trig->private_data; | 22 | struct adis *adis = iio_trigger_get_drvdata(trig); |
23 | 23 | ||
24 | return adis_enable_irq(adis, state); | 24 | return adis_enable_irq(adis, state); |
25 | } | 25 | } |
@@ -57,7 +57,7 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) | |||
57 | 57 | ||
58 | adis->trig->dev.parent = &adis->spi->dev; | 58 | adis->trig->dev.parent = &adis->spi->dev; |
59 | adis->trig->ops = &adis_trigger_ops; | 59 | adis->trig->ops = &adis_trigger_ops; |
60 | adis->trig->private_data = adis; | 60 | iio_trigger_set_drvdata(adis->trig, adis); |
61 | ret = iio_trigger_register(adis->trig); | 61 | ret = iio_trigger_register(adis->trig); |
62 | 62 | ||
63 | indio_dev->trig = adis->trig; | 63 | indio_dev->trig = adis->trig; |
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c index e1d0869e0ad1..03b9372c1212 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | |||
@@ -103,7 +103,7 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) | |||
103 | static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig, | 103 | static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig, |
104 | bool state) | 104 | bool state) |
105 | { | 105 | { |
106 | return inv_mpu6050_set_enable(trig->private_data, state); | 106 | return inv_mpu6050_set_enable(iio_trigger_get_drvdata(trig), state); |
107 | } | 107 | } |
108 | 108 | ||
109 | static const struct iio_trigger_ops inv_mpu_trigger_ops = { | 109 | static const struct iio_trigger_ops inv_mpu_trigger_ops = { |
@@ -130,8 +130,8 @@ int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev) | |||
130 | if (ret) | 130 | if (ret) |
131 | goto error_free_trig; | 131 | goto error_free_trig; |
132 | st->trig->dev.parent = &st->client->dev; | 132 | st->trig->dev.parent = &st->client->dev; |
133 | st->trig->private_data = indio_dev; | ||
134 | st->trig->ops = &inv_mpu_trigger_ops; | 133 | st->trig->ops = &inv_mpu_trigger_ops; |
134 | iio_trigger_set_drvdata(st->trig, indio_dev); | ||
135 | ret = iio_trigger_register(st->trig); | 135 | ret = iio_trigger_register(st->trig); |
136 | if (ret) | 136 | if (ret) |
137 | goto error_free_irq; | 137 | goto error_free_irq; |