iio: mxs-lradc: only update the buffer when its conversions have finished
authorKristina Martšenko <kristina.martsenko@gmail.com>
Sun, 25 Jan 2015 16:28:22 +0000 (18:28 +0200)
committerJonathan Cameron <jic23@kernel.org>
Mon, 26 Jan 2015 21:00:54 +0000 (21:00 +0000)
Using the touchscreen while running buffered capture results in the
buffer reporting lots of wrong values, often just zeros. This is because
we push readings to the buffer every time a touchscreen interrupt
arrives, including when the buffer's own conversions have not yet
finished. So let's only push to the buffer when its conversions are
ready.

Signed-off-by: Kristina Martšenko <kristina.martsenko@gmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Cc: Stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/adc/mxs-lradc.c

index d2e0c275bf4d09383ee59bb3eba1b26155147c1e..ebcbd12d48b9c10767c692621fffcffad87798b5 100644 (file)
@@ -1152,10 +1152,12 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data)
                                LRADC_CTRL1_LRADC_IRQ(TOUCHSCREEN_VCHANNEL2));
        }
 
-       if (iio_buffer_enabled(iio))
-               iio_trigger_poll(iio->trig);
-       else if (reg & LRADC_CTRL1_LRADC_IRQ(0))
+       if (iio_buffer_enabled(iio)) {
+               if (reg & lradc->buffer_vchans)
+                       iio_trigger_poll(iio->trig);
+       } else if (reg & LRADC_CTRL1_LRADC_IRQ(0)) {
                complete(&lradc->completion);
+       }
 
        mxs_lradc_reg_clear(lradc, reg & clr_irq, LRADC_CTRL1);