Skip to content

Commit e2d4cdb

Browse files
fgasnier63gregkh
authored andcommitted
iio: adc: stm32: fix scan of multiple channels with DMA
commit 04e491c upstream. By default, watermark is set to '1'. Watermark is used to fine tune cyclic dma buffer period. In case watermark is left untouched (e.g. 1) and several channels are being scanned, buffer period is wrongly set (e.g. to 1 sample). As a consequence, data is never pushed to upper layer. Fix buffer period size, by taking scan channels number into account. Fixes: 2763ea0 ("iio: adc: stm32: add optional dma support") Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cfd96cb commit e2d4cdb

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎drivers/iio/adc/stm32-adc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
13141314
{
13151315
struct stm32_adc *adc = iio_priv(indio_dev);
13161316
unsigned int watermark = STM32_DMA_BUFFER_SIZE / 2;
1317+
unsigned int rx_buf_sz = STM32_DMA_BUFFER_SIZE;
13171318

13181319
/*
13191320
* dma cyclic transfers are used, buffer is split into two periods.
@@ -1322,7 +1323,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val)
13221323
* - one buffer (period) driver can push with iio_trigger_poll().
13231324
*/
13241325
watermark = min(watermark, val * (unsigned)(sizeof(u16)));
1325-
adc->rx_buf_sz = watermark * 2;
1326+
adc->rx_buf_sz = min(rx_buf_sz, watermark * 2 * adc->num_conv);
13261327

13271328
return 0;
13281329
}

0 commit comments

Comments
 (0)