[PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment

Md Shofiqul Islam posted 1 patch 1 month ago
There is a newer version of this series
drivers/iio/adc/ti-ads1298.c | 4 ++--
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment
Posted by Md Shofiqul Islam 1 month ago
At the lowest supported data rate of 250Hz, one conversion period is
4ms, not 40ms. The 50ms timeout is deliberately conservative to allow
for kernel scheduling latency, which can be significant under load or
on slow machines.

Fix the comment to state the correct conversion time, use "lowest sample
rate" for clarity, and explain that the extra margin exists to absorb
scheduling latency so that no one is tempted to shrink the timeout to
match the conversion period.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
 drivers/iio/adc/ti-ads1298.c | 4 ++--
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c
index cf5f954206..6625d9f0d0 100644
--- a/drivers/iio/adc/ti-ads1298.c
+++ b/drivers/iio/adc/ti-ads1298.c
@@ -210,7 +210,9 @@ static int ads1298_read_one(struct ads1298_private *priv, int chan_index)
 		return ret;
 	}

-	/* Cannot take longer than 40ms (250Hz) */
+	/* One conversion takes at most 4ms at the lowest sample rate (250Hz).
+	 * Use 50ms to allow for kernel scheduling latency.
+	 */
 	ret = wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50));
 	if (!ret)
 		return -ETIMEDOUT;
--
2.54.0.windows.1
Re: [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment
Posted by Andy Shevchenko 1 month ago
On Sun, May 10, 2026 at 11:45:30AM +0300, Md Shofiqul Islam wrote:
> At the lowest supported data rate of 250Hz, one conversion period is
> 4ms, not 40ms. The 50ms timeout is deliberately conservative to allow
> for kernel scheduling latency, which can be significant under load or
> on slow machines.
> 
> Fix the comment to state the correct conversion time, use "lowest sample
> rate" for clarity, and explain that the extra margin exists to absorb
> scheduling latency so that no one is tempted to shrink the timeout to
> match the conversion period.

...

> -	/* Cannot take longer than 40ms (250Hz) */
> +	/* One conversion takes at most 4ms at the lowest sample rate (250Hz).
> +	 * Use 50ms to allow for kernel scheduling latency.
> +	 */

/*
 * This is wrong style of multi-line comments in the IIO
 * subsystem. Use this example on how to fix it.
 */

-- 
With Best Regards,
Andy Shevchenko