staging:iio:adc:ad7150 fix event codes.
authorJonathan Cameron <jic23@cam.ac.uk>
Wed, 18 May 2011 13:42:13 +0000 (14:42 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 19 May 2011 23:15:00 +0000 (16:15 -0700)
I won't guarantee I got these right, but they are certainly closer than
the abuse of buffer event codes that was perviously in here.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/iio/adc/ad7150.c

index cbd1f96188c39684bad7bcee436b871e1c2f0ea0..e23bb9960019b83370314c2e67fed63302c05915 100644 (file)
@@ -642,11 +642,6 @@ static const struct attribute_group ad7150_attribute_group = {
  * threshold events
  */
 
-#define IIO_EVENT_CODE_CH1_HIGH    IIO_BUFFER_EVENT_CODE(0)
-#define IIO_EVENT_CODE_CH1_LOW     IIO_BUFFER_EVENT_CODE(1)
-#define IIO_EVENT_CODE_CH2_HIGH    IIO_BUFFER_EVENT_CODE(2)
-#define IIO_EVENT_CODE_CH2_LOW     IIO_BUFFER_EVENT_CODE(3)
-
 static irqreturn_t ad7150_event_handler(int irq, void *private)
 {
        struct iio_dev *indio_dev = private;
@@ -658,21 +653,33 @@ static irqreturn_t ad7150_event_handler(int irq, void *private)
 
        if ((int_status & AD7150_STATUS_OUT1) && !(chip->old_state & AD7150_STATUS_OUT1))
                iio_push_event(indio_dev, 0,
-                               IIO_EVENT_CODE_CH1_HIGH,
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
                                timestamp);
        else if ((!(int_status & AD7150_STATUS_OUT1)) && (chip->old_state & AD7150_STATUS_OUT1))
                iio_push_event(indio_dev, 0,
-                               IIO_EVENT_CODE_CH1_LOW,
-                               timestamp);
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   0,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
 
        if ((int_status & AD7150_STATUS_OUT2) && !(chip->old_state & AD7150_STATUS_OUT2))
                iio_push_event(indio_dev, 0,
-                               IIO_EVENT_CODE_CH2_HIGH,
-                               timestamp);
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   1,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_RISING),
+                              timestamp);
        else if ((!(int_status & AD7150_STATUS_OUT2)) && (chip->old_state & AD7150_STATUS_OUT2))
                iio_push_event(indio_dev, 0,
-                               IIO_EVENT_CODE_CH2_LOW,
-                               timestamp);
+                              IIO_UNMOD_EVENT_CODE(IIO_EV_CLASS_IN,
+                                                   1,
+                                                   IIO_EV_TYPE_THRESH,
+                                                   IIO_EV_DIR_FALLING),
+                              timestamp);
        return IRQ_HANDLED;
 }