diff options
author | Denis Ciocca <denis.ciocca@st.com> | 2019-08-02 13:59:13 -0400 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-08-05 11:50:08 -0400 |
commit | 9cd15d521a3adcb687a0f9a312e32caaa94f44c2 (patch) | |
tree | 2b51376c4064455b43b37f2c6507d3e8bf37ca9d | |
parent | 48cceecfa7625e700ed9c57392bd17923c4832c0 (diff) |
iio: remove get_irq_data_ready() function pointer and use IRQ number directly
Not even sure why it was there since the beginning. Just use IRQ
number in the sensor_data struct.
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | drivers/iio/accel/st_accel_core.c | 7 | ||||
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_i2c.c | 9 | ||||
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_spi.c | 9 | ||||
-rw-r--r-- | drivers/iio/common/st_sensors/st_sensors_trigger.c | 21 | ||||
-rw-r--r-- | drivers/iio/gyro/st_gyro_core.c | 7 | ||||
-rw-r--r-- | drivers/iio/magnetometer/st_magn_core.c | 7 | ||||
-rw-r--r-- | drivers/iio/pressure/st_pressure_core.c | 7 | ||||
-rw-r--r-- | include/linux/iio/common/st_sensors.h | 5 |
8 files changed, 26 insertions, 46 deletions
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 0b17004cb12e..2e37f8a6d8cf 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c | |||
@@ -1169,7 +1169,6 @@ int st_accel_common_probe(struct iio_dev *indio_dev) | |||
1169 | struct st_sensor_data *adata = iio_priv(indio_dev); | 1169 | struct st_sensor_data *adata = iio_priv(indio_dev); |
1170 | struct st_sensors_platform_data *pdata = | 1170 | struct st_sensors_platform_data *pdata = |
1171 | (struct st_sensors_platform_data *)adata->dev->platform_data; | 1171 | (struct st_sensors_platform_data *)adata->dev->platform_data; |
1172 | int irq = adata->get_irq_data_ready(indio_dev); | ||
1173 | struct iio_chan_spec *channels; | 1172 | struct iio_chan_spec *channels; |
1174 | size_t channels_size; | 1173 | size_t channels_size; |
1175 | int err; | 1174 | int err; |
@@ -1217,7 +1216,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) | |||
1217 | if (err < 0) | 1216 | if (err < 0) |
1218 | goto st_accel_power_off; | 1217 | goto st_accel_power_off; |
1219 | 1218 | ||
1220 | if (irq > 0) { | 1219 | if (adata->irq > 0) { |
1221 | err = st_sensors_allocate_trigger(indio_dev, | 1220 | err = st_sensors_allocate_trigger(indio_dev, |
1222 | ST_ACCEL_TRIGGER_OPS); | 1221 | ST_ACCEL_TRIGGER_OPS); |
1223 | if (err < 0) | 1222 | if (err < 0) |
@@ -1234,7 +1233,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) | |||
1234 | return 0; | 1233 | return 0; |
1235 | 1234 | ||
1236 | st_accel_device_register_error: | 1235 | st_accel_device_register_error: |
1237 | if (irq > 0) | 1236 | if (adata->irq > 0) |
1238 | st_sensors_deallocate_trigger(indio_dev); | 1237 | st_sensors_deallocate_trigger(indio_dev); |
1239 | st_accel_probe_trigger_error: | 1238 | st_accel_probe_trigger_error: |
1240 | st_accel_deallocate_ring(indio_dev); | 1239 | st_accel_deallocate_ring(indio_dev); |
@@ -1252,7 +1251,7 @@ void st_accel_common_remove(struct iio_dev *indio_dev) | |||
1252 | st_sensors_power_disable(indio_dev); | 1251 | st_sensors_power_disable(indio_dev); |
1253 | 1252 | ||
1254 | iio_device_unregister(indio_dev); | 1253 | iio_device_unregister(indio_dev); |
1255 | if (adata->get_irq_data_ready(indio_dev) > 0) | 1254 | if (adata->irq > 0) |
1256 | st_sensors_deallocate_trigger(indio_dev); | 1255 | st_sensors_deallocate_trigger(indio_dev); |
1257 | 1256 | ||
1258 | st_accel_deallocate_ring(indio_dev); | 1257 | st_accel_deallocate_ring(indio_dev); |
diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index 9240625534df..aa89d54a7c59 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c | |||
@@ -20,13 +20,6 @@ | |||
20 | 20 | ||
21 | #define ST_SENSORS_I2C_MULTIREAD 0x80 | 21 | #define ST_SENSORS_I2C_MULTIREAD 0x80 |
22 | 22 | ||
23 | static unsigned int st_sensors_i2c_get_irq(struct iio_dev *indio_dev) | ||
24 | { | ||
25 | struct st_sensor_data *sdata = iio_priv(indio_dev); | ||
26 | |||
27 | return to_i2c_client(sdata->dev)->irq; | ||
28 | } | ||
29 | |||
30 | static const struct regmap_config st_sensors_i2c_regmap_config = { | 23 | static const struct regmap_config st_sensors_i2c_regmap_config = { |
31 | .reg_bits = 8, | 24 | .reg_bits = 8, |
32 | .val_bits = 8, | 25 | .val_bits = 8, |
@@ -69,7 +62,7 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev, | |||
69 | indio_dev->name = client->name; | 62 | indio_dev->name = client->name; |
70 | 63 | ||
71 | sdata->dev = &client->dev; | 64 | sdata->dev = &client->dev; |
72 | sdata->get_irq_data_ready = st_sensors_i2c_get_irq; | 65 | sdata->irq = client->irq; |
73 | 66 | ||
74 | return 0; | 67 | return 0; |
75 | } | 68 | } |
diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c index 9c0661a283d0..2262f81b07c2 100644 --- a/drivers/iio/common/st_sensors/st_sensors_spi.c +++ b/drivers/iio/common/st_sensors/st_sensors_spi.c | |||
@@ -18,13 +18,6 @@ | |||
18 | 18 | ||
19 | #define ST_SENSORS_SPI_MULTIREAD 0xc0 | 19 | #define ST_SENSORS_SPI_MULTIREAD 0xc0 |
20 | 20 | ||
21 | static unsigned int st_sensors_spi_get_irq(struct iio_dev *indio_dev) | ||
22 | { | ||
23 | struct st_sensor_data *sdata = iio_priv(indio_dev); | ||
24 | |||
25 | return to_spi_device(sdata->dev)->irq; | ||
26 | } | ||
27 | |||
28 | static const struct regmap_config st_sensors_spi_regmap_config = { | 21 | static const struct regmap_config st_sensors_spi_regmap_config = { |
29 | .reg_bits = 8, | 22 | .reg_bits = 8, |
30 | .val_bits = 8, | 23 | .val_bits = 8, |
@@ -117,7 +110,7 @@ int st_sensors_spi_configure(struct iio_dev *indio_dev, | |||
117 | indio_dev->name = spi->modalias; | 110 | indio_dev->name = spi->modalias; |
118 | 111 | ||
119 | sdata->dev = &spi->dev; | 112 | sdata->dev = &spi->dev; |
120 | sdata->get_irq_data_ready = st_sensors_spi_get_irq; | 113 | sdata->irq = spi->irq; |
121 | 114 | ||
122 | return 0; | 115 | return 0; |
123 | } | 116 | } |
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index bed7b8682b17..4a2efa00f7f2 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c | |||
@@ -121,9 +121,9 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p) | |||
121 | int st_sensors_allocate_trigger(struct iio_dev *indio_dev, | 121 | int st_sensors_allocate_trigger(struct iio_dev *indio_dev, |
122 | const struct iio_trigger_ops *trigger_ops) | 122 | const struct iio_trigger_ops *trigger_ops) |
123 | { | 123 | { |
124 | int err, irq; | ||
125 | struct st_sensor_data *sdata = iio_priv(indio_dev); | 124 | struct st_sensor_data *sdata = iio_priv(indio_dev); |
126 | unsigned long irq_trig; | 125 | unsigned long irq_trig; |
126 | int err; | ||
127 | 127 | ||
128 | sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name); | 128 | sdata->trig = iio_trigger_alloc("%s-trigger", indio_dev->name); |
129 | if (sdata->trig == NULL) { | 129 | if (sdata->trig == NULL) { |
@@ -135,8 +135,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, | |||
135 | sdata->trig->ops = trigger_ops; | 135 | sdata->trig->ops = trigger_ops; |
136 | sdata->trig->dev.parent = sdata->dev; | 136 | sdata->trig->dev.parent = sdata->dev; |
137 | 137 | ||
138 | irq = sdata->get_irq_data_ready(indio_dev); | 138 | irq_trig = irqd_get_trigger_type(irq_get_irq_data(sdata->irq)); |
139 | irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq)); | ||
140 | /* | 139 | /* |
141 | * If the IRQ is triggered on falling edge, we need to mark the | 140 | * If the IRQ is triggered on falling edge, we need to mark the |
142 | * interrupt as active low, if the hardware supports this. | 141 | * interrupt as active low, if the hardware supports this. |
@@ -206,12 +205,12 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, | |||
206 | sdata->sensor_settings->drdy_irq.stat_drdy.addr) | 205 | sdata->sensor_settings->drdy_irq.stat_drdy.addr) |
207 | irq_trig |= IRQF_SHARED; | 206 | irq_trig |= IRQF_SHARED; |
208 | 207 | ||
209 | err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev), | 208 | err = request_threaded_irq(sdata->irq, |
210 | st_sensors_irq_handler, | 209 | st_sensors_irq_handler, |
211 | st_sensors_irq_thread, | 210 | st_sensors_irq_thread, |
212 | irq_trig, | 211 | irq_trig, |
213 | sdata->trig->name, | 212 | sdata->trig->name, |
214 | sdata->trig); | 213 | sdata->trig); |
215 | if (err) { | 214 | if (err) { |
216 | dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n"); | 215 | dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n"); |
217 | goto iio_trigger_free; | 216 | goto iio_trigger_free; |
@@ -227,7 +226,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, | |||
227 | return 0; | 226 | return 0; |
228 | 227 | ||
229 | iio_trigger_register_error: | 228 | iio_trigger_register_error: |
230 | free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); | 229 | free_irq(sdata->irq, sdata->trig); |
231 | iio_trigger_free: | 230 | iio_trigger_free: |
232 | iio_trigger_free(sdata->trig); | 231 | iio_trigger_free(sdata->trig); |
233 | return err; | 232 | return err; |
@@ -239,7 +238,7 @@ void st_sensors_deallocate_trigger(struct iio_dev *indio_dev) | |||
239 | struct st_sensor_data *sdata = iio_priv(indio_dev); | 238 | struct st_sensor_data *sdata = iio_priv(indio_dev); |
240 | 239 | ||
241 | iio_trigger_unregister(sdata->trig); | 240 | iio_trigger_unregister(sdata->trig); |
242 | free_irq(sdata->get_irq_data_ready(indio_dev), sdata->trig); | 241 | free_irq(sdata->irq, sdata->trig); |
243 | iio_trigger_free(sdata->trig); | 242 | iio_trigger_free(sdata->trig); |
244 | } | 243 | } |
245 | EXPORT_SYMBOL(st_sensors_deallocate_trigger); | 244 | EXPORT_SYMBOL(st_sensors_deallocate_trigger); |
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index 02e42c945181..c0acbb5d2ffb 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c | |||
@@ -388,7 +388,6 @@ EXPORT_SYMBOL(st_gyro_get_settings); | |||
388 | int st_gyro_common_probe(struct iio_dev *indio_dev) | 388 | int st_gyro_common_probe(struct iio_dev *indio_dev) |
389 | { | 389 | { |
390 | struct st_sensor_data *gdata = iio_priv(indio_dev); | 390 | struct st_sensor_data *gdata = iio_priv(indio_dev); |
391 | int irq = gdata->get_irq_data_ready(indio_dev); | ||
392 | int err; | 391 | int err; |
393 | 392 | ||
394 | indio_dev->modes = INDIO_DIRECT_MODE; | 393 | indio_dev->modes = INDIO_DIRECT_MODE; |
@@ -419,7 +418,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) | |||
419 | if (err < 0) | 418 | if (err < 0) |
420 | goto st_gyro_power_off; | 419 | goto st_gyro_power_off; |
421 | 420 | ||
422 | if (irq > 0) { | 421 | if (gdata->irq > 0) { |
423 | err = st_sensors_allocate_trigger(indio_dev, | 422 | err = st_sensors_allocate_trigger(indio_dev, |
424 | ST_GYRO_TRIGGER_OPS); | 423 | ST_GYRO_TRIGGER_OPS); |
425 | if (err < 0) | 424 | if (err < 0) |
@@ -436,7 +435,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) | |||
436 | return 0; | 435 | return 0; |
437 | 436 | ||
438 | st_gyro_device_register_error: | 437 | st_gyro_device_register_error: |
439 | if (irq > 0) | 438 | if (gdata->irq > 0) |
440 | st_sensors_deallocate_trigger(indio_dev); | 439 | st_sensors_deallocate_trigger(indio_dev); |
441 | st_gyro_probe_trigger_error: | 440 | st_gyro_probe_trigger_error: |
442 | st_gyro_deallocate_ring(indio_dev); | 441 | st_gyro_deallocate_ring(indio_dev); |
@@ -454,7 +453,7 @@ void st_gyro_common_remove(struct iio_dev *indio_dev) | |||
454 | st_sensors_power_disable(indio_dev); | 453 | st_sensors_power_disable(indio_dev); |
455 | 454 | ||
456 | iio_device_unregister(indio_dev); | 455 | iio_device_unregister(indio_dev); |
457 | if (gdata->get_irq_data_ready(indio_dev) > 0) | 456 | if (gdata->irq > 0) |
458 | st_sensors_deallocate_trigger(indio_dev); | 457 | st_sensors_deallocate_trigger(indio_dev); |
459 | 458 | ||
460 | st_gyro_deallocate_ring(indio_dev); | 459 | st_gyro_deallocate_ring(indio_dev); |
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 804353a483c7..a3a268ee2896 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c | |||
@@ -490,7 +490,6 @@ EXPORT_SYMBOL(st_magn_get_settings); | |||
490 | int st_magn_common_probe(struct iio_dev *indio_dev) | 490 | int st_magn_common_probe(struct iio_dev *indio_dev) |
491 | { | 491 | { |
492 | struct st_sensor_data *mdata = iio_priv(indio_dev); | 492 | struct st_sensor_data *mdata = iio_priv(indio_dev); |
493 | int irq = mdata->get_irq_data_ready(indio_dev); | ||
494 | int err; | 493 | int err; |
495 | 494 | ||
496 | indio_dev->modes = INDIO_DIRECT_MODE; | 495 | indio_dev->modes = INDIO_DIRECT_MODE; |
@@ -520,7 +519,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) | |||
520 | if (err < 0) | 519 | if (err < 0) |
521 | goto st_magn_power_off; | 520 | goto st_magn_power_off; |
522 | 521 | ||
523 | if (irq > 0) { | 522 | if (mdata->irq > 0) { |
524 | err = st_sensors_allocate_trigger(indio_dev, | 523 | err = st_sensors_allocate_trigger(indio_dev, |
525 | ST_MAGN_TRIGGER_OPS); | 524 | ST_MAGN_TRIGGER_OPS); |
526 | if (err < 0) | 525 | if (err < 0) |
@@ -537,7 +536,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) | |||
537 | return 0; | 536 | return 0; |
538 | 537 | ||
539 | st_magn_device_register_error: | 538 | st_magn_device_register_error: |
540 | if (irq > 0) | 539 | if (mdata->irq > 0) |
541 | st_sensors_deallocate_trigger(indio_dev); | 540 | st_sensors_deallocate_trigger(indio_dev); |
542 | st_magn_probe_trigger_error: | 541 | st_magn_probe_trigger_error: |
543 | st_magn_deallocate_ring(indio_dev); | 542 | st_magn_deallocate_ring(indio_dev); |
@@ -555,7 +554,7 @@ void st_magn_common_remove(struct iio_dev *indio_dev) | |||
555 | st_sensors_power_disable(indio_dev); | 554 | st_sensors_power_disable(indio_dev); |
556 | 555 | ||
557 | iio_device_unregister(indio_dev); | 556 | iio_device_unregister(indio_dev); |
558 | if (mdata->get_irq_data_ready(indio_dev) > 0) | 557 | if (mdata->irq > 0) |
559 | st_sensors_deallocate_trigger(indio_dev); | 558 | st_sensors_deallocate_trigger(indio_dev); |
560 | 559 | ||
561 | st_magn_deallocate_ring(indio_dev); | 560 | st_magn_deallocate_ring(indio_dev); |
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 9ef92a501286..ca6863b32a5f 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c | |||
@@ -686,7 +686,6 @@ int st_press_common_probe(struct iio_dev *indio_dev) | |||
686 | struct st_sensor_data *press_data = iio_priv(indio_dev); | 686 | struct st_sensor_data *press_data = iio_priv(indio_dev); |
687 | struct st_sensors_platform_data *pdata = | 687 | struct st_sensors_platform_data *pdata = |
688 | (struct st_sensors_platform_data *)press_data->dev->platform_data; | 688 | (struct st_sensors_platform_data *)press_data->dev->platform_data; |
689 | int irq = press_data->get_irq_data_ready(indio_dev); | ||
690 | int err; | 689 | int err; |
691 | 690 | ||
692 | indio_dev->modes = INDIO_DIRECT_MODE; | 691 | indio_dev->modes = INDIO_DIRECT_MODE; |
@@ -729,7 +728,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) | |||
729 | if (err < 0) | 728 | if (err < 0) |
730 | goto st_press_power_off; | 729 | goto st_press_power_off; |
731 | 730 | ||
732 | if (irq > 0) { | 731 | if (press_data->irq > 0) { |
733 | err = st_sensors_allocate_trigger(indio_dev, | 732 | err = st_sensors_allocate_trigger(indio_dev, |
734 | ST_PRESS_TRIGGER_OPS); | 733 | ST_PRESS_TRIGGER_OPS); |
735 | if (err < 0) | 734 | if (err < 0) |
@@ -746,7 +745,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) | |||
746 | return err; | 745 | return err; |
747 | 746 | ||
748 | st_press_device_register_error: | 747 | st_press_device_register_error: |
749 | if (irq > 0) | 748 | if (press_data->irq > 0) |
750 | st_sensors_deallocate_trigger(indio_dev); | 749 | st_sensors_deallocate_trigger(indio_dev); |
751 | st_press_probe_trigger_error: | 750 | st_press_probe_trigger_error: |
752 | st_press_deallocate_ring(indio_dev); | 751 | st_press_deallocate_ring(indio_dev); |
@@ -764,7 +763,7 @@ void st_press_common_remove(struct iio_dev *indio_dev) | |||
764 | st_sensors_power_disable(indio_dev); | 763 | st_sensors_power_disable(indio_dev); |
765 | 764 | ||
766 | iio_device_unregister(indio_dev); | 765 | iio_device_unregister(indio_dev); |
767 | if (press_data->get_irq_data_ready(indio_dev) > 0) | 766 | if (press_data->irq > 0) |
768 | st_sensors_deallocate_trigger(indio_dev); | 767 | st_sensors_deallocate_trigger(indio_dev); |
769 | 768 | ||
770 | st_press_deallocate_ring(indio_dev); | 769 | st_press_deallocate_ring(indio_dev); |
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 28fc1f9fa7d5..4d0889bf1c6c 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h | |||
@@ -220,7 +220,7 @@ struct st_sensor_settings { | |||
220 | * num_data_channels: Number of data channels used in buffer. | 220 | * num_data_channels: Number of data channels used in buffer. |
221 | * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). | 221 | * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). |
222 | * @int_pin_open_drain: Set the interrupt/DRDY to open drain. | 222 | * @int_pin_open_drain: Set the interrupt/DRDY to open drain. |
223 | * @get_irq_data_ready: Function to get the IRQ used for data ready signal. | 223 | * @irq: the IRQ number. |
224 | * @edge_irq: the IRQ triggers on edges and need special handling. | 224 | * @edge_irq: the IRQ triggers on edges and need special handling. |
225 | * @hw_irq_trigger: if we're using the hardware interrupt on the sensor. | 225 | * @hw_irq_trigger: if we're using the hardware interrupt on the sensor. |
226 | * @hw_timestamp: Latest timestamp from the interrupt handler, when in use. | 226 | * @hw_timestamp: Latest timestamp from the interrupt handler, when in use. |
@@ -244,8 +244,7 @@ struct st_sensor_data { | |||
244 | 244 | ||
245 | u8 drdy_int_pin; | 245 | u8 drdy_int_pin; |
246 | bool int_pin_open_drain; | 246 | bool int_pin_open_drain; |
247 | 247 | int irq; | |
248 | unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev); | ||
249 | 248 | ||
250 | bool edge_irq; | 249 | bool edge_irq; |
251 | bool hw_irq_trigger; | 250 | bool hw_irq_trigger; |