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

iio: adc: ad7380: fix SPI offload trigger rate

Add a special case to double the SPI offload trigger rate when all
channels of a single-ended chip are enabled in a buffered read.

The single-ended chips in the AD738x family can only do simultaneous
sampling of half their channels and have a multiplexer to allow reading
the other half. To comply with the IIO definition of sampling_frequency,
we need to trigger twice as often when the sequencer is enabled to so
that both banks can be read in a single sample period.

Fixes: bbeaec81a03e ("iio: ad7380: add support for SPI offload")
Signed-off-by: David Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
63275731 9b45744b

+8
+8
drivers/iio/adc/ad7380.c
··· 1227 1227 if (ret) 1228 1228 return ret; 1229 1229 1230 + /* 1231 + * When the sequencer is required to read all channels, we need to 1232 + * trigger twice per sample period in order to read one complete set 1233 + * of samples. 1234 + */ 1235 + if (st->seq) 1236 + config.periodic.frequency_hz *= 2; 1237 + 1230 1238 ret = spi_offload_trigger_enable(st->offload, st->offload_trigger, &config); 1231 1239 if (ret) 1232 1240 spi_unoptimize_message(&st->offload_msg);