Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: a5f8c7da3dbe ("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>

authored by

Jonathan Santos and committed by
Jonathan Cameron
8be19e23 185f7b6c

+7 -2
+7 -2
drivers/iio/adc/ad7768-1.c
··· 463 463 struct ad7768_state *st = iio_priv(indio_dev); 464 464 int readval, ret; 465 465 466 - reinit_completion(&st->completion); 467 - 468 466 ret = ad7768_set_mode(st, AD7768_ONE_SHOT); 469 467 if (ret < 0) 468 + return ret; 469 + 470 + reinit_completion(&st->completion); 471 + 472 + /* One-shot mode requires a SYNC pulse to generate a new sample */ 473 + ret = ad7768_send_sync_pulse(st); 474 + if (ret) 470 475 return ret; 471 476 472 477 ret = wait_for_completion_timeout(&st->completion,