Skip to contentSkip to conversation

staging: rtl8723bs: replace msleep with usleep_range

PATCH In review Marcos Andrade 2 participants 2 messages Mar 14 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: replace msleep with usleep_range

The msleep() function is not recommended for delays under 20ms as it may sleep for longer than desired. Replace msleep(10) with usleep_range(10000, 11000) to ensure a more precise delay and better kernel scheduling behavior.
This resolves a checkpatch.pl warning.

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +2 -1
index abb84f8ae..261d2e306 100644
@@ -4,6 +4,7 @@
  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
  *
  ******************************************************************************/
+#include "linux/delay.h"
 #include <drv_types.h>
 #include <hal_btcoex.h>
 #include <linux/jiffies.h>
@@ -214,7 +215,7 @@ void _rtw_free_evt_priv(struct	evt_priv *pevtpriv)
 {
 	_cancel_workitem_sync(&pevtpriv->c2h_wk);
 	while (pevtpriv->c2h_wk_alive)
-		msleep(10);
+		usleep_range(10000, 11000);
 
 	while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
 		void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 7 lines · Marcos Andrade

The msleep() function is not recommended for delays under 20ms as it may sleep for longer than desired. Replace msleep(10) with usleep_range(10000, 11000) to ensure a more precise delay and better kernel scheduling behavior.
This resolves a checkpatch.pl warning.

...

Quoted 1 line

+#include "linux/delay.h"

This would be <linux/delay.h>.

Quoted 3 lines

#include <drv_types.h>
#include <hal_btcoex.h>
#include <linux/jiffies.h>

This has already came up before and Greg decided to drop it. [1]

Thanks,

ET

[1] https://lore.kernel.org/linux-staging/[email protected]/