diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-05-18 09:42:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 19:15:01 -0400 |
commit | b206c3bbb4eda4f82c3396c0cc3a4443ffc166c5 (patch) | |
tree | 0729b3db757d5e615b971272cd611dbb6324a06b | |
parent | 0bb8be643161ae1dc5c5a0255cf5ca20f7de7b5a (diff) |
staging:iio:adc:ad7291 remove abuse of buffer events and replace with something almost sane
This device has separate events for a sort of decaying average and for
the raw value. We don't have a way of specifying this as yet.
For now I have both resulting in the same event code.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/iio/adc/ad7291.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 527311c1d3bf..0e4c7283bb07 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c | |||
@@ -454,12 +454,6 @@ static const struct attribute_group ad7291_attribute_group = { | |||
454 | * temperature bound events | 454 | * temperature bound events |
455 | */ | 455 | */ |
456 | 456 | ||
457 | #define IIO_EVENT_CODE_AD7291_T_SENSE_HIGH IIO_BUFFER_EVENT_CODE(0) | ||
458 | #define IIO_EVENT_CODE_AD7291_T_SENSE_LOW IIO_BUFFER_EVENT_CODE(1) | ||
459 | #define IIO_EVENT_CODE_AD7291_T_AVG_HIGH IIO_BUFFER_EVENT_CODE(2) | ||
460 | #define IIO_EVENT_CODE_AD7291_T_AVG_LOW IIO_BUFFER_EVENT_CODE(3) | ||
461 | #define IIO_EVENT_CODE_AD7291_VOLTAGE_BASE IIO_BUFFER_EVENT_CODE(4) | ||
462 | |||
463 | static irqreturn_t ad7291_event_handler(int irq, void *private) | 457 | static irqreturn_t ad7291_event_handler(int irq, void *private) |
464 | { | 458 | { |
465 | struct iio_dev *indio_dev = private; | 459 | struct iio_dev *indio_dev = private; |
@@ -484,18 +478,50 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) | |||
484 | command = chip->command & ~AD7291_ALART_CLEAR; | 478 | command = chip->command & ~AD7291_ALART_CLEAR; |
485 | ad7291_i2c_write(chip, AD7291_COMMAND, command); | 479 | ad7291_i2c_write(chip, AD7291_COMMAND, command); |
486 | 480 | ||
487 | for (i = 0; i < 4; i++) { | 481 | if (t_status & (1 << 0)) |
488 | if (t_status & (1 << i)) | 482 | iio_push_event(indio_dev, 0, |
489 | iio_push_event(indio_dev, 0, | 483 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, |
490 | IIO_EVENT_CODE_AD7291_T_SENSE_HIGH + i, | 484 | 0, |
491 | timestamp); | 485 | IIO_EV_TYPE_THRESH, |
492 | } | 486 | IIO_EV_DIR_FALLING), |
493 | 487 | timestamp); | |
494 | for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i++) { | 488 | if (t_status & (1 << 1)) |
489 | iio_push_event(indio_dev, 0, | ||
490 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, | ||
491 | 0, | ||
492 | IIO_EV_TYPE_THRESH, | ||
493 | IIO_EV_DIR_RISING), | ||
494 | timestamp); | ||
495 | if (t_status & (1 << 2)) | ||
496 | iio_push_event(indio_dev, 0, | ||
497 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, | ||
498 | 0, | ||
499 | IIO_EV_TYPE_THRESH, | ||
500 | IIO_EV_DIR_FALLING), | ||
501 | timestamp); | ||
502 | if (t_status & (1 << 3)) | ||
503 | iio_push_event(indio_dev, 0, | ||
504 | IIO_UNMOD_EVENT_CODE(IIO_TEMP, | ||
505 | 0, | ||
506 | IIO_EV_TYPE_THRESH, | ||
507 | IIO_EV_DIR_RISING), | ||
508 | timestamp); | ||
509 | |||
510 | for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) { | ||
495 | if (v_status & (1 << i)) | 511 | if (v_status & (1 << i)) |
496 | iio_push_event(indio_dev, 0, | 512 | iio_push_event(indio_dev, 0, |
497 | IIO_EVENT_CODE_AD7291_VOLTAGE_BASE + i, | 513 | IIO_UNMOD_EVENT_CODE(IIO_IN, |
498 | timestamp); | 514 | i/2, |
515 | IIO_EV_TYPE_THRESH, | ||
516 | IIO_EV_DIR_FALLING), | ||
517 | timestamp); | ||
518 | if (v_status & (1 << (i + 1))) | ||
519 | iio_push_event(indio_dev, 0, | ||
520 | IIO_UNMOD_EVENT_CODE(IIO_IN, | ||
521 | i/2, | ||
522 | IIO_EV_TYPE_THRESH, | ||
523 | IIO_EV_DIR_RISING), | ||
524 | timestamp); | ||
499 | } | 525 | } |
500 | 526 | ||
501 | return IRQ_HANDLED; | 527 | return IRQ_HANDLED; |