Skip to contentSkip to conversation

staging: rtl8723bs: Replace msleep with usleep_range

PATCH In review AyushMukkanwar 3 participants 3 messages Mar 19 – Mar 20 Staging

lore
Share & tools
lore
#0 lore raw

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

The checkpatch.pl script flagged a warning regarding the use of msleep() for less than 20ms. msleep() relies on jiffies and can be inaccurate for short durations, leading to inefficient delays.

Replace msleep(10) with usleep_range(10000, 12000) to allow for timer coalescing. This gives the kernel scheduler a 2ms window to group wakeups, improving overall system power efficiency while maintaining the required 10ms minimum delay.

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
index abb84f8aecbe..bab48392f296 100644
@@ -214,7 +214,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, 12000);
 
 	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 11 lines · AyushMukkanwar

The checkpatch.pl script flagged a warning regarding the use of msleep() for less than 20ms. msleep() relies on jiffies and can be inaccurate for short durations, leading to inefficient delays.

Replace msleep(10) with usleep_range(10000, 12000) to allow for timer coalescing. This gives the kernel scheduler a 2ms window to group wakeups, improving overall system power efficiency while maintaining the required 10ms minimum delay.

---

Greg has already NAKed this change.

Thanks,

ET

#2 lore raw
In reply to AyushMukkanwar
Quoted 8 lines · AyushMukkanwar

The checkpatch.pl script flagged a warning regarding the use of msleep() for less than 20ms. msleep() relies on jiffies and can be inaccurate for short durations, leading to inefficient delays.

Replace msleep(10) with usleep_range(10000, 12000) to allow for timer coalescing. This gives the kernel scheduler a 2ms window to group wakeups, improving overall system power efficiency while maintaining the required 10ms minimum delay.

The new API is fsleep().

Signature · 2 lines
With Best Regards,
Andy Shevchenko