From: Paul Cercueil Date: Mon, 17 Jan 2022 10:25:12 +0000 (+0000) Subject: iio: at91-sama5d2: Limit requested watermark value to hwfifo size X-Git-Tag: howlett/maple/20220816~205^2~26^2~34 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=754d013433bc7cf4677223ccd8dcbeb2a09c9982;p=users%2Fjedix%2Flinux-maple.git iio: at91-sama5d2: Limit requested watermark value to hwfifo size Instead of returning an error if the watermark value is too high, which the core will silently ignore anyway, limit the value to the hardware FIFO size; a lower-than-requested value is still better than using the default, which is usually 1. Cc: Eugen Hristev Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Paul Cercueil Link: https://lore.kernel.org/r/20220117102512.31725-2-paul@crapouillou.net Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index b764823ce57e..fe3131c9593c 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1752,7 +1752,7 @@ static int at91_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) int ret; if (val > AT91_HWFIFO_MAX_SIZE) - return -EINVAL; + val = AT91_HWFIFO_MAX_SIZE; if (!st->selected_trig->hw_trig) { dev_dbg(&indio_dev->dev, "we need hw trigger for DMA\n");