* [PATCH] staging: rtl8723bs: refactor code flow and fix sleep ranges
@ 2026-04-18 16:47 deep
2026-04-26 19:51 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: deep @ 2026-04-18 16:47 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Dan Carpenter, Michael Straube, linux-staging, linux-kernel,
Kenet Jovan Sokoli
From: Kenet Jovan Sokoli <deep@crimson.net.eu.org>
Clean up core files to improve readability and style compliance
- Flatten deeply nested if-statements mainly in rtw_security.c.
- Correct usleep_range() arguments where min > max.
- Improve code flow and readability by using early returns/breaks.
Signed-off-by: Kenet Jovan Sokoli <deep@crimson.net.eu.org>
---
some if statements still give warnings when checked with checkpatch.pl.
I thought about removing them entirely since they're currently blank,
but decided against it. If it is necessary to revert them or delete them,
please let me know.
---
drivers/staging/rtl8723bs/core/rtw_cmd.c | 3 +-
drivers/staging/rtl8723bs/core/rtw_mlme.c | 8 +-
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 +-
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 6 +-
drivers/staging/rtl8723bs/core/rtw_recv.c | 10 +-
drivers/staging/rtl8723bs/core/rtw_security.c | 120 +++++++++---------
drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 +-
7 files changed, 77 insertions(+), 76 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index abb84f8aecbe..439591608c84 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -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);
+ usleep_range(10000, 11000);
while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 1ef48bf6581c..dd9d6af127ab 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -501,7 +501,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t
}
if (rtw_roam_flags(adapter)) {
- /* TODO: don't select network in the same ess as oldest if it's new enough*/
+ /* TODO: don't select network in the same ess as oldest if it's new enough */
}
if (!oldest || time_after(oldest->last_scanned, pnetwork->last_scanned))
@@ -1195,10 +1195,8 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
rtw_free_stainfo(adapter, pcur_sta);
ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.mac_address);
- if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
- if (ptarget_wlan)
- ptarget_wlan->fixed = true;
- }
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && ptarget_wlan)
+ ptarget_wlan->fixed = true;
}
} else {
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b1f20aa81efb..53bc015c0deb 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -9,6 +9,7 @@
#include <hal_btcoex.h>
#include <linux/kernel.h>
#include <linux/unaligned.h>
+#include <linux/delay.h>
static struct mlme_handler mlme_sta_tbl[] = {
{WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq},
@@ -5833,7 +5834,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)
return H2C_SUCCESS;
if ((pstapriv->tim_bitmap & BIT(0)) && (psta_bmc->sleepq_len > 0)) {
- msleep(10);/* 10ms, ATIM(HIQ) Windows */
+ usleep_range(10000, 11000);/* 10ms, ATIM(HIQ) Windows */
/* spin_lock_bh(&psta_bmc->sleep_q.lock); */
spin_lock_bh(&pxmitpriv->lock);
diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
index 1c9e02732687..e78f80f9d3b5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c
@@ -7,6 +7,7 @@
#include <drv_types.h>
#include <hal_data.h>
#include <linux/jiffies.h>
+#include <linux/delay.h>
void _ips_enter(struct adapter *padapter)
{
@@ -420,7 +421,7 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms)
err = -1;
break;
}
- msleep(1);
+ usleep_range(1000, 2000);
}
return err;
@@ -571,7 +572,7 @@ void LPS_Leave_check(struct adapter *padapter)
if (jiffies_to_msecs(jiffies - start_time) > 100)
break;
- msleep(1);
+ usleep_range(1000, 2000);
}
}
@@ -991,6 +992,7 @@ void rtw_free_pwrctrl_priv(struct adapter *adapter)
inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
{
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
+
pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms);
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 337671b1211f..a83d60dbd3ea 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1339,11 +1339,10 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f
}
- if (ret == _FAIL) {
+ if (ret == _FAIL)
goto exit;
- } else if (ret == RTW_RX_HANDLED) {
+ else if (ret == RTW_RX_HANDLED)
goto exit;
- }
if (!psta) {
@@ -1593,7 +1592,7 @@ static signed int wlanhdr_to_ethhdr(union recv_frame *precvframe)
eth_type = ntohs(be_tmp); /* pattrib->ether_type */
pattrib->eth_type = eth_type;
- if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
ptr += rmv_len;
*ptr = 0x87;
*(ptr+1) = 0x12;
@@ -1837,8 +1836,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un
/* Duplicate entry is found!! Do not insert current entry. */
/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */
return false;
- else
- break;
+ break;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index b489babe7432..084dda858582 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -521,82 +521,82 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data;
/* 4 start to decrypt recvframe */
- if (prxattrib->encrypt == _TKIP_) {
- stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
- if (stainfo) {
- if (is_multicast_ether_addr(prxattrib->ra)) {
- static unsigned long start;
- static u32 no_gkey_bc_cnt;
- static u32 no_gkey_mc_cnt;
+ if (prxattrib->encrypt != _TKIP_)
+ goto exit;
- if (!psecuritypriv->binstallGrpkey) {
- res = _FAIL;
+ stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
+ if (!stainfo) {
+ res = _FAIL;
+ goto exit;
+ }
- if (start == 0)
- start = jiffies;
+ if (is_multicast_ether_addr(prxattrib->ra)) {
+ static unsigned long start;
+ static u32 no_gkey_bc_cnt;
+ static u32 no_gkey_mc_cnt;
- if (is_broadcast_mac_addr(prxattrib->ra))
- no_gkey_bc_cnt++;
- else
- no_gkey_mc_cnt++;
+ if (!psecuritypriv->binstallGrpkey) {
+ res = _FAIL;
- if (jiffies_to_msecs(jiffies - start) > 1000) {
- if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter),
- no_gkey_bc_cnt,
- no_gkey_mc_cnt);
- }
- start = jiffies;
- no_gkey_bc_cnt = 0;
- no_gkey_mc_cnt = 0;
- }
- goto exit;
- }
+ if (start == 0)
+ start = jiffies;
- if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
- netdev_dbg(padapter->pnetdev,
- FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
- FUNC_ADPT_ARG(padapter),
- no_gkey_bc_cnt,
- no_gkey_mc_cnt);
- }
- start = 0;
+ if (is_broadcast_mac_addr(prxattrib->ra))
+ no_gkey_bc_cnt++;
+ else
+ no_gkey_mc_cnt++;
+
+ if (jiffies_to_msecs(jiffies - start) > 1000 && (no_gkey_bc_cnt || no_gkey_mc_cnt)) {
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
+ start = jiffies;
no_gkey_bc_cnt = 0;
no_gkey_mc_cnt = 0;
-
- prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
- } else {
- prwskey = &stainfo->dot118021x_UncstKey.skey[0];
}
+ goto exit;
+ }
- iv = pframe + prxattrib->hdrlen;
- payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
- length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
+ if (no_gkey_bc_cnt || no_gkey_mc_cnt) {
+ netdev_dbg(padapter->pnetdev,
+ FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n",
+ FUNC_ADPT_ARG(padapter),
+ no_gkey_bc_cnt,
+ no_gkey_mc_cnt);
+ }
+ start = 0;
+ no_gkey_bc_cnt = 0;
+ no_gkey_mc_cnt = 0;
- GET_TKIP_PN(iv, dot11txpn);
+ prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
+ } else {
+ prwskey = &stainfo->dot118021x_UncstKey.skey[0];
+ }
- pnl = (u16)(dot11txpn.val);
- pnh = (u32)(dot11txpn.val >> 16);
+ iv = pframe + prxattrib->hdrlen;
+ payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
+ length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
- phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);
- phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
+ GET_TKIP_PN(iv, dot11txpn);
- /* 4 decrypt payload include icv */
+ pnl = (u16)(dot11txpn.val);
+ pnh = (u32)(dot11txpn.val >> 16);
- arc4_setkey(ctx, rc4key, 16);
- arc4_crypt(ctx, payload, payload, length);
+ phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);
+ phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
- *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
+ /* 4 decrypt payload include icv */
- if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
- crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
- res = _FAIL;
- } else {
- res = _FAIL;
- }
- }
+ arc4_setkey(ctx, rc4key, 16);
+ arc4_crypt(ctx, payload, payload, length);
+
+ *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
+
+ if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
+ crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
+ res = _FAIL;
exit:
return res;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 7b18be8912e6..1904b9162262 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -5,6 +5,7 @@
*
******************************************************************************/
#include <drv_types.h>
+#include <linux/delay.h>
static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
@@ -128,7 +129,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
/* Tx buf allocation may fail sometimes, so sleep and retry. */
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true);
if (res == _FAIL) {
- msleep(10);
+ usleep_range(10000, 11000);
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true);
if (res == _FAIL)
goto exit;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] staging: rtl8723bs: refactor code flow and fix sleep ranges
2026-04-18 16:47 [PATCH] staging: rtl8723bs: refactor code flow and fix sleep ranges deep
@ 2026-04-26 19:51 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-26 19:51 UTC (permalink / raw)
To: deep; +Cc: Dan Carpenter, Michael Straube, linux-staging, linux-kernel
On Sat, Apr 18, 2026 at 06:47:19PM +0200, deep@crimson.net.eu.org wrote:
> From: Kenet Jovan Sokoli <deep@crimson.net.eu.org>
>
> Clean up core files to improve readability and style compliance
>
> - Flatten deeply nested if-statements mainly in rtw_security.c.
> - Correct usleep_range() arguments where min > max.
> - Improve code flow and readability by using early returns/breaks.
>
> Signed-off-by: Kenet Jovan Sokoli <deep@crimson.net.eu.org>
> ---
> some if statements still give warnings when checked with checkpatch.pl.
> I thought about removing them entirely since they're currently blank,
> but decided against it. If it is necessary to revert them or delete them,
> please let me know.
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch did many different things all at once, making it difficult
to review. All Linux kernel patches need to only do one thing at a
time. If you need to do multiple things (such as clean up all coding
style issues in a file/driver), do it in a sequence of patches, each
one doing only one thing. This will make it easier to review the
patches to ensure that they are correct, and to help alleviate any
merge issues that larger patches can cause.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-27 3:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-18 16:47 [PATCH] staging: rtl8723bs: refactor code flow and fix sleep ranges deep
2026-04-26 19:51 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox