mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
iio: adc: ad7768-1: fix one-shot mode data acquisition
According to the datasheet, one-shot mode requires a SYNC_IN pulse to
trigger a new sample conversion. In the current implementation, No sync
pulse was sent after switching to one-shot mode and reinit_completion()
was called before mode switching, creating a race condition where spurious
interrupts during mode change could trigger completion prematurely.
Fix by sending a sync pulse after configuring one-shot mode and
reinit_completion() to ensure it only waits for the actual conversion
completion.
Fixes: a5f8c7da3d ("iio: adc: Add AD7768-1 ADC basic support")
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
185f7b6cee
commit
8be19e2337
|
|
@ -463,12 +463,17 @@ static int ad7768_scan_direct(struct iio_dev *indio_dev)
|
|||
struct ad7768_state *st = iio_priv(indio_dev);
|
||||
int readval, ret;
|
||||
|
||||
reinit_completion(&st->completion);
|
||||
|
||||
ret = ad7768_set_mode(st, AD7768_ONE_SHOT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
reinit_completion(&st->completion);
|
||||
|
||||
/* One-shot mode requires a SYNC pulse to generate a new sample */
|
||||
ret = ad7768_send_sync_pulse(st);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = wait_for_completion_timeout(&st->completion,
|
||||
msecs_to_jiffies(1000));
|
||||
if (!ret)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user