Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment
       [not found] <20260509071910.12345-1-shofiqtest@gmail.com>
@ 2026-05-10  8:45 ` Md Shofiqul Islam
  2026-05-10 10:16   ` Andy Shevchenko
  2026-05-10 12:38 ` [PATCH v3] " Md Shofiqul Islam
  1 sibling, 1 reply; 6+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10  8:45 UTC (permalink / raw)
  To: jic23
  Cc: linux-iio, linux-kernel, dlechner, mike.looijmans, nuno.sa, andy,
	Md Shofiqul Islam

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment
  2026-05-10  8:45 ` [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment Md Shofiqul Islam
@ 2026-05-10 10:16   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-05-10 10:16 UTC (permalink / raw)
  To: Md Shofiqul Islam
  Cc: jic23, linux-iio, linux-kernel, dlechner, mike.looijmans, nuno.sa,
	andy

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3] iio: adc: ti-ads1298: Fix incorrect timeout comment
       [not found] <20260509071910.12345-1-shofiqtest@gmail.com>
  2026-05-10  8:45 ` [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment Md Shofiqul Islam
@ 2026-05-10 12:38 ` Md Shofiqul Islam
  2026-05-10 13:01   ` Andy Shevchenko
                     ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 12:38 UTC (permalink / raw)
  To: jic23
  Cc: dlechner, andy, nuno.sa, mike.looijmans, linux-iio, linux-kernel,
	Md Shofiqul Islam

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c
index cf5f954206..128b45a301 100644
--- a/drivers/iio/adc/ti-ads1298.c
+++ b/drivers/iio/adc/ti-ads1298.c
@@ -210,7 +210,11 @@ 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] iio: adc: ti-ads1298: Fix incorrect timeout comment
  2026-05-10 12:38 ` [PATCH v3] " Md Shofiqul Islam
@ 2026-05-10 13:01   ` Andy Shevchenko
  2026-05-10 19:34   ` [PATCH v4] " Md Shofiqul Islam
  2026-05-10 19:36   ` Md Shofiqul Islam
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-05-10 13:01 UTC (permalink / raw)
  To: Md Shofiqul Islam
  Cc: jic23, dlechner, andy, nuno.sa, mike.looijmans, linux-iio,
	linux-kernel

On Sun, May 10, 2026 at 03:38:01PM +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.
> 
> Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
> ---

Here should be a changelog. What's different to v2 to v1?

> -	/* 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;

It's also better to drop a ret assignment here as it's counter intuitive.

	if (!wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50)))
		return -ETIMEDOUT;

(This might require more changes related to this ret drop.)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4] iio: adc: ti-ads1298: Fix incorrect timeout comment
  2026-05-10 12:38 ` [PATCH v3] " Md Shofiqul Islam
  2026-05-10 13:01   ` Andy Shevchenko
@ 2026-05-10 19:34   ` Md Shofiqul Islam
  2026-05-10 19:36   ` Md Shofiqul Islam
  2 siblings, 0 replies; 6+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 19:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, lars, andy.shevchenko, david.lechner, mike

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.

Also drop the redundant ret variable assignment by using the return value
of wait_for_completion_timeout() directly in the if() condition.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
Changes in v4:
 - Drop the ret assignment for wait_for_completion_timeout(); use the
   return value directly in the if() condition (Andy Shevchenko)

Changes in v3:
 - Fix multi-line comment style: move comment text to its own line
   after '/*' (Andy Shevchenko)

Changes in v2:
 - Correct conversion time to 4ms (was wrong 40ms), add scheduling
   latency explanation, clarify "lowest sample rate" (David Lechner,
   Andy Shevchenko)

 drivers/iio/adc/ti-ads1298.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c
index ae30b47e45..25261163d3 100644
--- a/drivers/iio/adc/ti-ads1298.c
+++ b/drivers/iio/adc/ti-ads1298.c
@@ -210,9 +210,11 @@ static int ads1298_read_one(struct ads1298_private *priv, int chan_index)
 		return ret;
 	}
 
-	/* Cannot take longer than 40ms (250Hz) */
-	ret = wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50));
-	if (!ret)
+	/*
+	 * One conversion takes at most 4ms at the lowest sample rate (250Hz).
+	 * Use 50ms to allow for kernel scheduling latency.
+	 */
+	if (!wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50)))
 		return -ETIMEDOUT;
 
 	return 0;
-- 
2.54.0.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4] iio: adc: ti-ads1298: Fix incorrect timeout comment
  2026-05-10 12:38 ` [PATCH v3] " Md Shofiqul Islam
  2026-05-10 13:01   ` Andy Shevchenko
  2026-05-10 19:34   ` [PATCH v4] " Md Shofiqul Islam
@ 2026-05-10 19:36   ` Md Shofiqul Islam
  2 siblings, 0 replies; 6+ messages in thread
From: Md Shofiqul Islam @ 2026-05-10 19:36 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, lars, andy.shevchenko, dlechner, mike.looijmans

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.

Also drop the redundant ret variable assignment by using the return value
of wait_for_completion_timeout() directly in the if() condition.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
Changes in v4:
 - Drop the ret assignment for wait_for_completion_timeout(); use the
   return value directly in the if() condition (Andy Shevchenko)

Changes in v3:
 - Fix multi-line comment style: move comment text to its own line
   after '/*' (Andy Shevchenko)

Changes in v2:
 - Correct conversion time to 4ms (was wrong 40ms), add scheduling
   latency explanation, clarify "lowest sample rate" (David Lechner,
   Andy Shevchenko)

 drivers/iio/adc/ti-ads1298.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1298.c b/drivers/iio/adc/ti-ads1298.c
index ae30b47e45..25261163d3 100644
--- a/drivers/iio/adc/ti-ads1298.c
+++ b/drivers/iio/adc/ti-ads1298.c
@@ -210,9 +210,11 @@ static int ads1298_read_one(struct ads1298_private *priv, int chan_index)
 		return ret;
 	}
 
-	/* Cannot take longer than 40ms (250Hz) */
-	ret = wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50));
-	if (!ret)
+	/*
+	 * One conversion takes at most 4ms at the lowest sample rate (250Hz).
+	 * Use 50ms to allow for kernel scheduling latency.
+	 */
+	if (!wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50)))
 		return -ETIMEDOUT;
 
 	return 0;
-- 
2.54.0.windows.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-10 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260509071910.12345-1-shofiqtest@gmail.com>
2026-05-10  8:45 ` [PATCH v2] iio: adc: ti-ads1298: Fix incorrect timeout comment Md Shofiqul Islam
2026-05-10 10:16   ` Andy Shevchenko
2026-05-10 12:38 ` [PATCH v3] " Md Shofiqul Islam
2026-05-10 13:01   ` Andy Shevchenko
2026-05-10 19:34   ` [PATCH v4] " Md Shofiqul Islam
2026-05-10 19:36   ` Md Shofiqul Islam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox