Skip to content

Commit d0f23d8

Browse files
shofiqtestjic23
authored andcommitted
iio: adc: ti-ads1298: Fix incorrect timeout comment
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> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent af74304 commit d0f23d8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/iio/adc/ti-ads1298.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ static int ads1298_read_one(struct ads1298_private *priv, int chan_index)
210210
return ret;
211211
}
212212

213-
/* Cannot take longer than 40ms (250Hz) */
214-
ret = wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50));
215-
if (!ret)
213+
/*
214+
* One conversion takes at most 4ms at the lowest sample rate (250Hz).
215+
* Use 50ms to allow for kernel scheduling latency.
216+
*/
217+
if (!wait_for_completion_timeout(&priv->completion, msecs_to_jiffies(50)))
216218
return -ETIMEDOUT;
217219

218220
return 0;

0 commit comments

Comments
 (0)