Skip to contentSkip to conversation

staging: rtl8723bs: replace msleep() with fsleep() in rtw_cmd.c

PATCH Superseded Jose A. Perez de Azpillaga 3 participants 7 messages Feb 26 – Feb 28 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: replace msleep() with fsleep() in rtw_cmd.c

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loop in rtw_chk_hi_queue_hdl() for consistency.

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +3 -2
index abb84f8aecbe..e2c5eb2d32ef 100644
@@ -8,6 +8,7 @@
 #include <hal_btcoex.h>
 #include <linux/jiffies.h>
 #include <linux/align.h>
+#include <linux/delay.h>
 
 static struct _cmd_callback rtw_cmd_callback[] = {
 	{GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
@@ -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);
+		fsleep(10 * 1000);
 
 	while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
 		void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
@@ -1495,7 +1496,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
 	rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
 
 	while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
-		msleep(100);
+		fsleep(100 * 1000);
 		rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
 	}
 

--
2.53.0

#1 lore raw
Quoted 9 lines · Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loop in rtw_chk_hi_queue_hdl() for consistency.

---

...

drivers/staging/rtl8723bs/core/rtw_cmd.c void _rtw_free_evt_priv(struct evt_priv *pevtpriv) · line 218

Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
 	_cancel_workitem_sync(&pevtpriv->c2h_wk);
 	while (pevtpriv->c2h_wk_alive)
-		msleep(10);
+		fsleep(10 * 1000);

It's better to use USEC_PER_MSEC instead of 1000 to avoid magic numbers.

...

drivers/staging/rtl8723bs/core/rtw_cmd.c static void rtw_chk_hi_queue_hdl(struct adapter *padapter) · line 1499

Quoted 3 lines
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
 	while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
-		msleep(100);
+		fsleep(100 * 1000);

Ditto.

Thanks,

ET

#2 lore raw

PATCH v2 1/1 staging: rtl8723bs: replace msleep() with fsleep() in rtw_cmd.c

In reply to Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency.

---
v2: changed to USEC_PER_MSEC instead of magic numbers

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +3 -2
index abb84f8aecbe..c689d3744ad4 100644
@@ -8,6 +8,7 @@
 #include <hal_btcoex.h>
 #include <linux/jiffies.h>
 #include <linux/align.h>
+#include <linux/delay.h>
 
 static struct _cmd_callback rtw_cmd_callback[] = {
 	{GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
@@ -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);
+		fsleep(10 * USEC_PER_MSEC);
 
 	while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
 		void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
@@ -1495,7 +1496,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
 	rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
 
 	while (!empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) {
-		msleep(100);
+		fsleep(100 * USEC_PER_MSEC);
 		rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty);
 	}
 

--
2.53.0

#3 lore raw
Quoted 11 lines · Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency.

---
v2: changed to USEC_PER_MSEC instead of magic numbers
---

^^^
Remove this.

Here's Dan Carpenters's resource on making a v2:

https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/

Thanks,

ET

#4 lore raw
Quoted 8 lines · Ethan Tidmore
Quoted 7 lines · Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency.

Quoted 7 lines
Quoted 4 lines

---
v2: changed to USEC_PER_MSEC instead of magic numbers
---

^^^
Remove this.

Having an extra --- cut off line doesn't matter. The other thing that you sometimes see is an extra blank line before the --- cut off line and that's fine too.

regards,
dan carpenter

#5 lore raw
Quoted 17 lines · Dan Carpenter
Quoted 8 lines · Ethan Tidmore
Quoted 7 lines · Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency.

Quoted 7 lines
Quoted 4 lines

---
v2: changed to USEC_PER_MSEC instead of magic numbers
---

^^^
Remove this.

Quoted 6 lines

Having an extra --- cut off line doesn't matter. The other thing that you sometimes see is an extra blank line before the --- cut off line and that's fine too.

regards,
dan carpenter

Oh ok, nice to know. I guess I assumed the last cut of line was the one that counted.

Thanks,

ET

Reviewed-by on v2 1/1
#6 lore raw
In reply to Jose A. Perez de Azpillaga
Quoted 7 lines · Jose A. Perez de Azpillaga

Replace msleep() with fsleep() in rtw_cmd.c to improve delay precision and follow modern kernel practices.

Specifically, this fixes a checkpatch warning for the 10ms delay in _rtw_free_evt_priv() and updates the 100ms polling loops in rtw_chk_hi_queue_hdl() and rtw_free_cmd_priv() for consistency.

Quoted 6 lines

---
v2: changed to USEC_PER_MSEC instead of magic numbers

---
 drivers/staging/rtl8723bs/core/rtw_cmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Sorry about the confusion, LGTM.

Thanks,

ET