[PATCH] staging: rtl8723bs: replace msleep with usleep_range in rtw_dev_unload

Gustavo Arantes posted 1 patch 1 month ago
drivers/staging/rtl8723bs/os_dep/os_intfs.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
[PATCH] staging: rtl8723bs: replace msleep with usleep_range in rtw_dev_unload
Posted by Gustavo Arantes 1 month ago
Replace msleep(10) with usleep_range(10000, 20000) in the command thread
shutdown loop in rtw_dev_unload(), since msleep() for values less than
20ms may not in fact sleep for the intended duration and will often
sleep for up to 20ms, as documented in
Documentation/timers/timers-howto.rst.

Also remove the unnecessary else branch after break and the associated
if braces to simplify the loop.

Signed-off-by: Gustavo Arantes <dev.gustavoa@gmail.com>
---
 drivers/staging/rtl8723bs/os_dep/os_intfs.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
index f2d64b05debb..b5fac9ebc3c7 100644
--- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c
@@ -986,12 +986,11 @@ void rtw_dev_unload(struct adapter *padapter)
 			rtw_stop_drv_threads(padapter);
 
 		while (atomic_read(&pcmdpriv->cmdthd_running)) {
-			if (cnt > 5) {
+			if (cnt > 5)
 				break;
-			} else {
-				cnt++;
-				msleep(10);
-			}
+
+			cnt++;
+			usleep_range(10000, 20000);
 		}
 
 		/* check the status of IPS */
-- 
2.53.0
Re: [PATCH] staging: rtl8723bs: replace msleep with usleep_range in rtw_dev_unload
Posted by Bryant Boatright 1 month ago
On Sun, Mar 08, 2026 at 06:56:19PM -0300, Gustavo Arantes wrote:
> Replace msleep(10) with usleep_range(10000, 20000) in the command thread
> shutdown loop in rtw_dev_unload(), since msleep() for values less than
> 20ms may not in fact sleep for the intended duration and will often
> sleep for up to 20ms, as documented in
> Documentation/timers/timers-howto.rst.
> 

This has been addressed in a thread recently and Gred said to drop the patch [1].

Best,

Bryant Boatright

[1] https://lore.kernel.org/linux-staging/20260214173139.49094-1-ofekalm100@gmail.com/