Commit bd967ca8af48bd56076fad77ac77a010f3efd21c
Committed by
Vaibhav Hiremath
1 parent
7fb9db4270
Exists in
v3.2_SMARCT335xPSP_04.06.00.11
and in
3 other branches
IIO: ti_adc: Avoid double threshold event
The threshold event handler is being called before the FIFO has actually reached the threshold. The current code receives a FIFO threshold event, masks the interrupt, clears the event, and schedules a workqueue. The workqueue is run, it empties the FIFO, and unmasks the interrupt. In the above sequence, after the event is cleared, it immediately retriggers since the FIFO remains beyond the threshold. When the IRQ is unmasked, this triggered event generates another IRQ. However, as the FIFO has just been emptied, it is likely to not contain enough samples. The waits to clear the event until the FIFO has actually been emptied, in the workqueue. The unmasking and masking of the interrupt remains unchanged. Signed-off-by: Russ Dill <Russ.Dill@ti.com>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
drivers/staging/iio/adc/ti_adc.c
... | ... | @@ -174,8 +174,6 @@ |
174 | 174 | } else { |
175 | 175 | wake_up_interruptible(&adc_dev->wq_data_avail); |
176 | 176 | } |
177 | - adc_writel(adc_dev, TSCADC_REG_IRQSTATUS, | |
178 | - TSCADC_IRQENB_FIFO1THRES); | |
179 | 177 | return IRQ_HANDLED; |
180 | 178 | } else { |
181 | 179 | return IRQ_NONE; |
... | ... | @@ -212,6 +210,8 @@ |
212 | 210 | } |
213 | 211 | |
214 | 212 | buffer->access->store_to(buffer, (u8 *) iBuf, iio_get_time_ns()); |
213 | + adc_writel(adc_dev, TSCADC_REG_IRQSTATUS, | |
214 | + TSCADC_IRQENB_FIFO1THRES); | |
215 | 215 | adc_writel(adc_dev, TSCADC_REG_IRQENABLE, |
216 | 216 | TSCADC_IRQENB_FIFO1THRES); |
217 | 217 |