Re: [PATCH] iio: adc: ad4000: Avoid potential double data word read
From: Andy Shevchenko
Date: Tue Apr 15 2025 - 14:03:36 EST
On Tue, Apr 15, 2025 at 3:21 PM Marcelo Schmitt
<marcelo.schmitt@xxxxxxxxxx> wrote:
>
> Currently, SPI-Engine offload module always sends 32-bit data elements to
> DMA engine. Appropriately, when set for SPI offloading, the IIO driver uses
> 32 storagebits for IIO ADC channel buffer elements. However, setting SPI
> transfer length according to storagebits (32-bits in case of offload) can
> lead to unnecessarily long transfers for ADCs that are 16-bit or less
> precision. Adjust AD4000 single-shot read to run transfers of 2 bytes when
> that is enough to get all ADC data bits.
...
> xfers[1].rx_buf = &st->scan.data;
> - xfers[1].len = BITS_TO_BYTES(chan->scan_type.storagebits);
> + xfers[1].len = chan->scan_type.realbits > 16 ? 4 : 2;
But wouldn't be logical to have
xfers[1].len = BITS_TO_BYTES(chan->scan_type.realbits);
?
--
With Best Regards,
Andy Shevchenko