[PATCH v3] staging: greybus: loopback: Use fsleep() for delay
From: pavankumaryalagada
Date: Fri Oct 23 2026 - 10:49:07 EST
From: Yalagada Pavan Kumar <pavankumaryalagada@xxxxxxxxx>
Replace the existing usleep_range() and msleep() calls with
a single call to fsleep(), simplifying the code and letting
fsleep() select the appropriate delay method based on the
requested time.
For short delays, fsleep() allows up to 25% extra time instead
of the fixed 100 microseconds. For longer delays, the old code
rounds the requested time down to whole milliseconds, while
fsleep() rounds it up when using msleep().
These changes may affect the time between loopback operations
and the reported performance.
Suggested-by: Alex Elder <elder@xxxxxxxxxxxx>
Signed-off-by: Yalagada Pavan Kumar <pavankumaryalagada@xxxxxxxxx>
Reviewed-by: Alex Elder <elder@xxxxxxxxxxxx>
---
v3:
- Clarify the reason for using fsleep() in the commit message
v2:
- Add more details about how fsleep() affects delays.
- Update the subject to include the loopback module.
v1: https://lore.kernel.org/outreachy/c482704b-903e-413d-ba7b-5bf31c0a6104@xxxxxxxxxxxx/T/#t
---
drivers/staging/greybus/loopback.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index efc69c10cffe..2fe845eaef29 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -898,12 +898,8 @@ static int gb_loopback_fn(void *data)
gb->send_count++;
mutex_unlock(&gb->mutex);
- if (us_wait) {
- if (us_wait < 20000)
- usleep_range(us_wait, us_wait + 100);
- else
- msleep(us_wait / 1000);
- }
+ if (us_wait)
+ fsleep(us_wait);
}
gb_pm_runtime_put_autosuspend(bundle);
--
2.43.0