staging: rtl8723bs: cleanup and indentation refactoring
v3 cover staging: rtl8723bs: cleanup and indentation refactoring
This series improves the code quality and readability of rtw_mlme_ext.c in the rtl8723bs driver.
The first patch refactors several deeply nested loops and if-statements by using guard clauses (continue statements). This flattens the logic and makes the code easier to follow.
The second patch addresses various style issues reported by checkpatch.pl, including line length exceeding 100 columns, unnecessary parentheses, and unnecessary braces.
Michael Huang (2):
staging: rtl8723bs: refactor nested loops to reduce indentation
staging: rtl8723bs: fix line length and coding style issues
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 142 ++++++++++-------- 1 file changed, 80 insertions(+), 62 deletions(-)
--
2.43.0
PATCH v3 1/2 staging: rtl8723bs: refactor nested loops to reduce indentation
Use guard clauses (continue statements) to flatten the logic in rtw_mlme_ext.c. This improves code readability by reducing deep nesting levels.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +35 -26
@@ -3682,32 +3682,31 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)spin_unlock_bh (&(pmlmepriv->scanned_queue.lock)); -for (i =0 ; i <8 ; i++) { -if (ICS [i][0 ] ==1 ) { -int j, k =0 ; +int j, k =0 ; - InfoContent[k] = i; -/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; +if (ICS [i][0 ] !=1 ) +continue ; -for (j =1 ; j <=14 ; j++) { -if (ICS [i][j] ==1 ) { -if (k <16 ) { - InfoContent[k] = j;/* channel number */ -/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } - } - } + InfoContent[k] = i; +/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; - pframe =rtw_set_ie (pframe,WLAN_EID_BSS_INTOLERANT_CHL_REPORT , k, InfoContent, &(pattrib->pktlen)); +for (j =1 ; j <=14 ; j++) { +if (ICS [i][j] !=1 ) +continue ; +if (k <16 ) { + InfoContent[k] = j;/* channel number */ +/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } } + pframe =rtw_set_ie (pframe, +WLAN_EID_BSS_INTOLERANT_CHL_REPORT , + k, InfoContent, &pattrib->pktlen); } - - }
@@ -3831,14 +3830,24 @@ void site_survey(struct adapter *padapter)int i;for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) { -if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { -/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ -if (padapter->registrypriv.wifi_spec) -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); -else -issue_probereq_ex (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ,0 ,0 ,0 ,0 ); -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); - } +if (!pmlmeext->sitesurvey_res.ssid[i].ssid_length) +continue ; + +/* IOT issue, When wifi_spec is not set. */ +/* Send one probe req without WPS IE. */ +if (padapter->registrypriv.wifi_spec) +issue_probereq (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL ); +else +issue_probereq_ex (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL , +0 ,0 ,0 ,0 ); + +issue_probereq (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL ); }if (pmlmeext->sitesurvey_res.scan_mode ==SCAN_ACTIVE ) {
Signature · 1 line
2.43.0
Re: [PATCH v3 1/2] staging: rtl8723bs: refactor nested loops to reduce indentation
Quoted 1 line · Michael Huang
Use guard clauses (continue statements) to flatten the logic in
Just say continue statements. I saw "Use guard" and thought you were going to use "guard statements" which is a different thing in the kernel.
Quoted 46 lines
rtw_mlme_ext.c. This improves code readability by reducing deep nesting levels.Signed-off-by Michael Huang <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-)drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +9
-16@@ -3682,32 +3682,31 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)spin_unlock_bh (&(pmlmepriv->scanned_queue.lock)); -for (i =0 ; i <8 ; i++) { -if (ICS [i][0 ] ==1 ) { -int j, k =0 ; +int j, k =0 ; - InfoContent[k] = i; -/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; +if (ICS [i][0 ] !=1 ) +continue ; -for (j =1 ; j <=14 ; j++) { -if (ICS [i][j] ==1 ) { -if (k <16 ) { - InfoContent[k] = j;/* channel number */ -/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } - } - } + InfoContent[k] = i; +/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; - pframe =rtw_set_ie (pframe,WLAN_EID_BSS_INTOLERANT_CHL_REPORT , k, InfoContent, &(pattrib->pktlen)); +for (j =1 ; j <=14 ; j++) { +if (ICS [i][j] !=1 ) +continue ;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static void issue_action_BSSCoexistPacket(struct adapter *padapter) · line 3708
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +8
-0+if (k <16 ) { + InfoContent[k] = j;/* channel number */ +/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } } + pframe =rtw_set_ie (pframe, +WLAN_EID_BSS_INTOLERANT_CHL_REPORT , + k, InfoContent, &pattrib->pktlen);
This is unrelated. Do it in a separate patch.
Quoted 13 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-5} - - }@@ -3831,14 +3830,24 @@ void site_survey(struct adapter *padapter)int i;for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) { -if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { -/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ -if (padapter->registrypriv.wifi_spec)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c void site_survey(struct adapter *padapter) · line 3837
Quoted 10 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5
-5-issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); - else - issue_probereq_ex(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL, 0, 0, 0, 0); -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); - } +if (!pmlmeext->sitesurvey_res.ssid[i].ssid_length) +continue ; + +/* IOT issue, When wifi_spec is not set. */ +/* Send one probe req without WPS IE. */
You can flip the conditions around without rephrasing the comments. Do that in a separate patch.
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c void site_survey(struct adapter *padapter) · line 3841
Quoted 4 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4
-0+if (padapter->registrypriv.wifi_spec) +issue_probereq (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL );
All these reformating and removing extra parens makes the patch harder to review. I understand that checkpatch complains if you don't do it, but it's unrelated to the change you are making so it needs to be done in a separate step. (I'm not your boss and I can't tell you what to do. If you don't want to do the second step you can also skip it. The point is don't do unrelated things in the same patch).
regards,
dan carpenter
PATCH v3 2/2 staging: rtl8723bs: fix line length and coding style issues
In reply to Michael HuangFix checkpatch.pl warnings regarding line length exceeding 100 columns, white spaces, and unnecessary braces in rtw_mlme_ext.c.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 81 ++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +45 -36
@@ -1120,11 +1120,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS );if (!wpa_ie) { -if (elems.wps_ie) { +if (elems.wps_ie) pstat->flags |=WLAN_STA_WPS ; - }else { +else pstat->flags |=WLAN_STA_MAYBE_WPS ; - }/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */
@@ -4939,7 +4938,9 @@ void _linked_info_dump(struct adapter *padapter)if (padapter->bLinkInfoDump) {if ((pmlmeinfo->state&0x03 ) ==WIFI_FW_STATION_STATE ) -rtw_hal_get_def_var (padapter,HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , &UndecoratedSmoothedPWDB); +rtw_hal_get_def_var (padapter, +HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , + &UndecoratedSmoothedPWDB);for (i =0 ; i <NUM_STA ; i++) {if (pdvobj->macid[i]) {
@@ -4978,7 +4979,6 @@ void linked_status_chk(struct adapter *padapter)struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;struct sta_priv *pstapriv = &padapter->stapriv; -if (is_client_associated_to_ap (padapter)) {/* linked infrastructure client mode */
@@ -4994,7 +4994,8 @@ void linked_status_chk(struct adapter *padapter) link_count_limit =7 ;/* 16 sec */ /* Marked by Kurt 20130715 */ -/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, so we could not check rx limit that strictly. */ +/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, */ +/* so we could not check rx limit that strictly. */ /* todo: To check why we under miracast session, rx_chk would be false */ psta =rtw_get_stainfo (pstapriv, pmlmeinfo->network.mac_address);if (psta) {
@@ -5007,9 +5008,18 @@ void linked_status_chk(struct adapter *padapter) {if (rx_chk != _SUCCESS) {if (pmlmeext->retry ==0 ) { -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); } }
@@ -5033,7 +5043,7 @@ void linked_status_chk(struct adapter *padapter) }if (tx_chk == _FAIL) { - pmlmeinfo->link_count %= (link_count_limit+1 ); + pmlmeinfo->link_count %= (link_count_limit +1 ); }else { pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; pmlmeinfo->link_count =0 ;
@@ -5051,7 +5061,6 @@ void linked_status_chk(struct adapter *padapter)continue ;if (pmlmeinfo->FW_sta_info[i].rx_pkt ==sta_rx_pkts (psta)) { -if (pmlmeinfo->FW_sta_info[i].retry <3 ) { pmlmeinfo->FW_sta_info[i].retry++; }else {
@@ -5069,9 +5078,7 @@ void linked_status_chk(struct adapter *padapter) }/* set_link_timer(pmlmeext, DISCONNECT_TO); */ - } - }void survey_timer_hdl (struct timer_list *t)
@@ -5195,7 +5202,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) type = _HW_STATE_AP_;/* start_ap_mode(padapter); */ }else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT (0 )|BIT (1 ));/* clear state */ + pmlmeinfo->state &= ~(BIT (0 ) |BIT (1 ));/* clear state */ pmlmeinfo->state |=WIFI_FW_STATION_STATE ;/* set to STATION_STATE */ type = _HW_STATE_STATION_; }else if (psetop->mode == Ndis802_11IBSS) {
@@ -5214,7 +5221,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) }return H2C_SUCCESS ; - }u8 createbss_hdl (struct adapter *padapter,u8 *pbuf)
@@ -5518,8 +5524,11 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) {if (pparm->ssid[i].ssid_length) { -memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, pparm->ssid[i].ssid,IW_ESSID_MAX_SIZE ); - pmlmeext->sitesurvey_res.ssid[i].ssid_length = pparm->ssid[i].ssid_length; +memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, + pparm->ssid[i].ssid, +IW_ESSID_MAX_SIZE ); + pmlmeext->sitesurvey_res.ssid[i].ssid_length = + pparm->ssid[i].ssid_length; }else { pmlmeext->sitesurvey_res.ssid[i].ssid_length =0 ; }
@@ -5547,7 +5556,8 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) } } -if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) { +if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || + (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) {/* disable dynamic functions, such as high power, DIG */ Save_DM_Func_Flag (padapter);Switch_DM_Func (padapter,DYNAMIC_FUNC_DISABLE , false);
@@ -5571,7 +5581,6 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)site_survey (padapter);return H2C_SUCCESS ; - }u8 setauth_hdl (struct adapter *padapter,unsigned char *pbuf)
@@ -5701,7 +5710,6 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)return H2C_SUCCESS ; } -u8 chk_bmc_sleepq_cmd (struct adapter *padapter) {struct cmd_obj *ph2c;
@@ -5747,8 +5755,8 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)memcpy (&(ptxBeacon_parm->network), &(pmlmeinfo->network),sizeof (struct wlan_bssid_ex )); - len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.ie_length-_BEACON_IE_OFFSET_, + len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies + _BEACON_IE_OFFSET_, + ptxBeacon_parm->network.ie_length - _BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.ie_length += len_diff;
@@ -5803,8 +5811,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff ); - evt_code = (u8)((*peventbuf>>16 )&0xff ); + evt_sz = (u16)(*peventbuf &0xffff ); + evt_code = (u8)((*peventbuf >>16 ) &0xff );/* checking if event code is valid */ if (evt_code >=MAX_C2HEVT )
@@ -5812,7 +5820,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)/* checking if event size match the event parm size */ if ((wlanevents[evt_code].parmsize !=0 ) && - (wlanevents[evt_code].parmsize != evt_sz)) + (wlanevents[evt_code].parmsize != evt_sz)) goto _abort_event_;atomic_inc (&pevt_priv->event_seq);
@@ -5826,12 +5834,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) pevt_priv->evt_done_cnt++; } - _abort_event_: - -return H2C_SUCCESS ; - }u8 h2c_msg_hdl (struct adapter *padapter,unsigned char *pbuf)
@@ -5855,7 +5859,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)if (!psta_bmc)return H2C_SUCCESS ; -if ((pstapriv->tim_bitmap&BIT (0 )) && (psta_bmc->sleepq_len >0 )) { +if ((pstapriv->tim_bitmap &BIT (0 )) && (psta_bmc->sleepq_len >0 )) {msleep (10 );/* 10ms, ATIM(HIQ) Windows */ /* spin_lock_bh(&psta_bmc->sleep_q.lock); */
@@ -5954,8 +5958,13 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; - pmlmeext->max_chan_nums =init_channel_set (padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); -init_channel_list (padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + pmlmeext->max_chan_nums =init_channel_set (padapter, + setChannelPlan_param->channel_plan, + pmlmeext->channel_set); +init_channel_list (padapter, + pmlmeext->channel_set, + pmlmeext->max_chan_nums, + &pmlmeext->channel_list);if (padapter->rtw_wdev && padapter->rtw_wdev->wiphy) {struct regulatory_request request;
@@ -5975,9 +5984,10 @@ u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf)/* TDLS_ESTABLISHED : write RCR DATA BIT */ /* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ /* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ -/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_DONE_CH_SEN : channel sensing and report candidate channel */ /* TDLS_OFF_CH : first time set channel to off channel */ -/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set */ +/* base channel as target channel */ /* TDLS_P_OFF_CH : periodically go to off channel */ /* TDLS_P_BASE_CH : periodically go back to base channel */ /* TDLS_RS_RCR : restore RCR */
@@ -5991,8 +6001,7 @@ u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf) {struct RunInThread_param *p; - -if (pbuf ==NULL ) +if (!pbuf)return H2C_PARAMETERS_ERROR ; p = (struct RunInThread_param *)pbuf;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 15 lines · Michael Huang
This series improves the code quality and readability of
rtw_mlme_ext.cin the rtl8723bs driver.The first patch refactors several deeply nested loops and if-statements by using guard clauses (continue statements). This flattens the logic and makes the code easier to follow.
The second patch addresses various style issues reported by checkpatch.pl, including line length exceeding 100 columns, unnecessary parentheses, and unnecessary braces.
Michael Huang (2):
staging: rtl8723bs: refactor nested loops to reduce indentation
staging: rtl8723bs: fix line length and coding style issues
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 142 ++++++++++-------- 1 file changed, 80 insertions(+), 62 deletions(-)--
2.43.0
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:
- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.
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
v4 cover staging: rtl8723bs: cleanup and indentation refactoring
In reply to Michael HuangThis series improves the code quality and readability of rtw_mlme_ext.c in the rtl8723bs driver.
The first patch refactors several deeply nested loops and if-statements by using guard clauses (continue statements). This flattens the logic and makes the code easier to follow.
The second patch addresses various style issues reported by checkpatch.pl, including line length exceeding 100 columns, unnecessary parentheses, and unnecessary braces.
---
Changes in v4:
- Corrected the patch format by moving the changelog below the "---" line in individual patches as requested by the automated bot.
- This version (v4) serves as the initial clean public submission.
Changes in v3:
- Split changes into a logical two-patch series.
- Fixed commit message line wrapping (75 chars).
- Added missing Signed-off-by tags.
- Fixed line length and alignment issues in the code.
Michael Huang (2):
staging: rtl8723bs: refactor nested loops to reduce indentation
staging: rtl8723bs: fix line length and coding style issues
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 142 ++++++++++-------- 1 file changed, 80 insertions(+), 62 deletions(-)
--
2.43.0
PATCH v4 1/2 staging: rtl8723bs: refactor nested loops to reduce indentation
Use guard clauses (continue statements) to flatten the logic in rtw_mlme_ext.c. This improves code readability by reducing deep nesting levels.
---
Changes in v4:
- Fix canonical patch format by moving the changelog below the "---" line.
- Initial public submission (corrected versioning).
Changes in v3:
- Fix line wrapping in commit description (under 75 chars).
- Properly align multi-line function parameters.
- Remove unnecessary parentheses.
- Add missing Signed-off-by tag.
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +35 -26
@@ -3682,32 +3682,31 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)spin_unlock_bh (&(pmlmepriv->scanned_queue.lock)); -for (i =0 ; i <8 ; i++) { -if (ICS [i][0 ] ==1 ) { -int j, k =0 ; +int j, k =0 ; - InfoContent[k] = i; -/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; +if (ICS [i][0 ] !=1 ) +continue ; -for (j =1 ; j <=14 ; j++) { -if (ICS [i][j] ==1 ) { -if (k <16 ) { - InfoContent[k] = j;/* channel number */ -/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } - } - } + InfoContent[k] = i; +/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; - pframe =rtw_set_ie (pframe,WLAN_EID_BSS_INTOLERANT_CHL_REPORT , k, InfoContent, &(pattrib->pktlen)); +for (j =1 ; j <=14 ; j++) { +if (ICS [i][j] !=1 ) +continue ; +if (k <16 ) { + InfoContent[k] = j;/* channel number */ +/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } } + pframe =rtw_set_ie (pframe, +WLAN_EID_BSS_INTOLERANT_CHL_REPORT , + k, InfoContent, &pattrib->pktlen); } - - }
@@ -3831,14 +3830,24 @@ void site_survey(struct adapter *padapter)int i;for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) { -if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { -/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ -if (padapter->registrypriv.wifi_spec) -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); -else -issue_probereq_ex (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ,0 ,0 ,0 ,0 ); -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); - } +if (!pmlmeext->sitesurvey_res.ssid[i].ssid_length) +continue ; + +/* IOT issue, When wifi_spec is not set. */ +/* Send one probe req without WPS IE. */ +if (padapter->registrypriv.wifi_spec) +issue_probereq (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL ); +else +issue_probereq_ex (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL , +0 ,0 ,0 ,0 ); + +issue_probereq (padapter, + &pmlmeext->sitesurvey_res.ssid[i], +NULL ); }if (pmlmeext->sitesurvey_res.scan_mode ==SCAN_ACTIVE ) {
--
2.43.0
PATCH v4 2/2 staging: rtl8723bs: fix line length and coding style issues
In reply to Michael HuangFix checkpatch.pl warnings regarding line length exceeding 100 columns, white spaces, and unnecessary braces in rtw_mlme_ext.c.
---
Changes in v4:
- Fix canonical patch format by moving the changelog below the "---" line.
- Initial public submission (corrected versioning).
Changes in v3:
- Fix line wrapping in commit description (under 75 chars).
- Fix line length exceeding 100 columns in comments.
- Add missing Signed-off-by tag.
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 81 ++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +45 -36
@@ -1120,11 +1120,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS );if (!wpa_ie) { -if (elems.wps_ie) { +if (elems.wps_ie) pstat->flags |=WLAN_STA_WPS ; - }else { +else pstat->flags |=WLAN_STA_MAYBE_WPS ; - }/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */
@@ -4939,7 +4938,9 @@ void _linked_info_dump(struct adapter *padapter)if (padapter->bLinkInfoDump) {if ((pmlmeinfo->state&0x03 ) ==WIFI_FW_STATION_STATE ) -rtw_hal_get_def_var (padapter,HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , &UndecoratedSmoothedPWDB); +rtw_hal_get_def_var (padapter, +HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , + &UndecoratedSmoothedPWDB);for (i =0 ; i <NUM_STA ; i++) {if (pdvobj->macid[i]) {
@@ -4978,7 +4979,6 @@ void linked_status_chk(struct adapter *padapter)struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;struct sta_priv *pstapriv = &padapter->stapriv; -if (is_client_associated_to_ap (padapter)) {/* linked infrastructure client mode */
@@ -4994,7 +4994,8 @@ void linked_status_chk(struct adapter *padapter) link_count_limit =7 ;/* 16 sec */ /* Marked by Kurt 20130715 */ -/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, so we could not check rx limit that strictly. */ +/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, */ +/* so we could not check rx limit that strictly. */ /* todo: To check why we under miracast session, rx_chk would be false */ psta =rtw_get_stainfo (pstapriv, pmlmeinfo->network.mac_address);if (psta) {
@@ -5007,9 +5008,18 @@ void linked_status_chk(struct adapter *padapter) {if (rx_chk != _SUCCESS) {if (pmlmeext->retry ==0 ) { -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); } }
@@ -5033,7 +5043,7 @@ void linked_status_chk(struct adapter *padapter) }if (tx_chk == _FAIL) { - pmlmeinfo->link_count %= (link_count_limit+1 ); + pmlmeinfo->link_count %= (link_count_limit +1 ); }else { pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; pmlmeinfo->link_count =0 ;
@@ -5051,7 +5061,6 @@ void linked_status_chk(struct adapter *padapter)continue ;if (pmlmeinfo->FW_sta_info[i].rx_pkt ==sta_rx_pkts (psta)) { -if (pmlmeinfo->FW_sta_info[i].retry <3 ) { pmlmeinfo->FW_sta_info[i].retry++; }else {
@@ -5069,9 +5078,7 @@ void linked_status_chk(struct adapter *padapter) }/* set_link_timer(pmlmeext, DISCONNECT_TO); */ - } - }void survey_timer_hdl (struct timer_list *t)
@@ -5195,7 +5202,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) type = _HW_STATE_AP_;/* start_ap_mode(padapter); */ }else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT (0 )|BIT (1 ));/* clear state */ + pmlmeinfo->state &= ~(BIT (0 ) |BIT (1 ));/* clear state */ pmlmeinfo->state |=WIFI_FW_STATION_STATE ;/* set to STATION_STATE */ type = _HW_STATE_STATION_; }else if (psetop->mode == Ndis802_11IBSS) {
@@ -5214,7 +5221,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) }return H2C_SUCCESS ; - }u8 createbss_hdl (struct adapter *padapter,u8 *pbuf)
@@ -5518,8 +5524,11 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) {if (pparm->ssid[i].ssid_length) { -memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, pparm->ssid[i].ssid,IW_ESSID_MAX_SIZE ); - pmlmeext->sitesurvey_res.ssid[i].ssid_length = pparm->ssid[i].ssid_length; +memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, + pparm->ssid[i].ssid, +IW_ESSID_MAX_SIZE ); + pmlmeext->sitesurvey_res.ssid[i].ssid_length = + pparm->ssid[i].ssid_length; }else { pmlmeext->sitesurvey_res.ssid[i].ssid_length =0 ; }
@@ -5547,7 +5556,8 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) } } -if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) { +if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || + (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) {/* disable dynamic functions, such as high power, DIG */ Save_DM_Func_Flag (padapter);Switch_DM_Func (padapter,DYNAMIC_FUNC_DISABLE , false);
@@ -5571,7 +5581,6 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)site_survey (padapter);return H2C_SUCCESS ; - }u8 setauth_hdl (struct adapter *padapter,unsigned char *pbuf)
@@ -5701,7 +5710,6 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)return H2C_SUCCESS ; } -u8 chk_bmc_sleepq_cmd (struct adapter *padapter) {struct cmd_obj *ph2c;
@@ -5747,8 +5755,8 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)memcpy (&(ptxBeacon_parm->network), &(pmlmeinfo->network),sizeof (struct wlan_bssid_ex )); - len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.ie_length-_BEACON_IE_OFFSET_, + len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies + _BEACON_IE_OFFSET_, + ptxBeacon_parm->network.ie_length - _BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.ie_length += len_diff;
@@ -5803,8 +5811,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff ); - evt_code = (u8)((*peventbuf>>16 )&0xff ); + evt_sz = (u16)(*peventbuf &0xffff ); + evt_code = (u8)((*peventbuf >>16 ) &0xff );/* checking if event code is valid */ if (evt_code >=MAX_C2HEVT )
@@ -5812,7 +5820,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)/* checking if event size match the event parm size */ if ((wlanevents[evt_code].parmsize !=0 ) && - (wlanevents[evt_code].parmsize != evt_sz)) + (wlanevents[evt_code].parmsize != evt_sz)) goto _abort_event_;atomic_inc (&pevt_priv->event_seq);
@@ -5826,12 +5834,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) pevt_priv->evt_done_cnt++; } - _abort_event_: - -return H2C_SUCCESS ; - }u8 h2c_msg_hdl (struct adapter *padapter,unsigned char *pbuf)
@@ -5855,7 +5859,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)if (!psta_bmc)return H2C_SUCCESS ; -if ((pstapriv->tim_bitmap&BIT (0 )) && (psta_bmc->sleepq_len >0 )) { +if ((pstapriv->tim_bitmap &BIT (0 )) && (psta_bmc->sleepq_len >0 )) {msleep (10 );/* 10ms, ATIM(HIQ) Windows */ /* spin_lock_bh(&psta_bmc->sleep_q.lock); */
@@ -5954,8 +5958,13 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; - pmlmeext->max_chan_nums =init_channel_set (padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); -init_channel_list (padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + pmlmeext->max_chan_nums =init_channel_set (padapter, + setChannelPlan_param->channel_plan, + pmlmeext->channel_set); +init_channel_list (padapter, + pmlmeext->channel_set, + pmlmeext->max_chan_nums, + &pmlmeext->channel_list);if (padapter->rtw_wdev && padapter->rtw_wdev->wiphy) {struct regulatory_request request;
@@ -5975,9 +5984,10 @@ u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf)/* TDLS_ESTABLISHED : write RCR DATA BIT */ /* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ /* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ -/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_DONE_CH_SEN : channel sensing and report candidate channel */ /* TDLS_OFF_CH : first time set channel to off channel */ -/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set */ +/* base channel as target channel */ /* TDLS_P_OFF_CH : periodically go to off channel */ /* TDLS_P_BASE_CH : periodically go back to base channel */ /* TDLS_RS_RCR : restore RCR */
@@ -5991,8 +6001,7 @@ u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf) {struct RunInThread_param *p; - -if (pbuf ==NULL ) +if (!pbuf)return H2C_PARAMETERS_ERROR ; p = (struct RunInThread_param *)pbuf;
--
2.43.0
Re: [PATCH v4 2/2] staging: rtl8723bs: fix line length and coding style issues
Quoted 2 lines · Michael Huang
Fix checkpatch.pl warnings regarding line length exceeding 100 columns, white spaces, and unnecessary braces in
rtw_mlme_ext.c.
Fix one type of warning per patch.
regards,
dan carpenter
v5 cover staging: rtl8723bs: cleanup and refactorcleanup and indentation refactoring
In reply to Michael HuangThis series refactors the function in rtw_mlme_ext.c to improve readability and comply with Linux kernel coding standards.
Following feedback from Dan Carpenter, this version (v5) deconstructs the previous changes into seven atomic patches. This separation ensures that logical changes (such as flattening nested loops) are isolated from purely stylistic cleanups (such as fixing indentation or NULL checks), making the review process more straightforward and less error-prone.
Each patch focuses on a single category of improvement:
1. Logic flattening: Use continue statements to reduce indentation.
2. Comment positioning: Adjust comments to align with new logic.
3. New lines cleanup: Removed unnecessary new lines
4. Line length compliance: Resolve 100-column limit warnings.
5. Operator spacing: Add missing spaces around logical operators.
6. Braces removal: Clean up unnecessary braces in single-line branches.
7. NULL check simplification: Use the "!ptr" convention for brevity.
---
Changes in v5:
- Split the series into 7 atomic patches for easier review.
- Renamed "guard clauses" to "continue statements" description per feedback.
- Separated logic changes, comment refactoring, and style cleanups.
- Fixed indentation issues (replaced spaces with tabs).
- Simplified NULL pointer checks to use the !ptr convention.
Changes in v4:
- Corrected the patch format by moving the changelog below the "---" line.
- Initial clean public submission of this series.
Michael Huang (7):
staging: rtl8723bs: use continue statements to reduce indentation
staging: rtl8723bs: refactor comments to fix the line length warning
for exceeding 100 columns
staging: rtl8723bs: remove unnecessary new lines
staging: rtl8723bs: Fix the line length exceeding 100 columns warning
in the code
staging: rtl8723bs: add missing space around operators
staging: rtl8723bs: remove unnecessary braces
staging: rtl8723bs: use !ptr instead of ptr == NULL
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 129 ++++++++++-------- 1 file changed, 70 insertions(+), 59 deletions(-)
--
2.43.0
PATCH v5 1/7 staging: rtl8723bs: use continue statements to reduce indentation
Refactor nested if-statements using "continue" statements. This flattens the logic, reduces deep indentation, and improves overall code readability.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +25 -23
@@ -3684,29 +3684,29 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)for (i =0 ; i <8 ; i++) { -if (ICS [i][0 ] ==1 ) { -int j, k =0 ; +int j, k =0 ; - InfoContent[k] = i; -/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; +if (ICS [i][0 ] !=1 ) +continue ; -for (j =1 ; j <=14 ; j++) { -if (ICS [i][j] ==1 ) { -if (k <16 ) { - InfoContent[k] = j;/* channel number */ -/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } - } - } + InfoContent[k] = i; +/* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; - pframe =rtw_set_ie (pframe,WLAN_EID_BSS_INTOLERANT_CHL_REPORT , k, InfoContent, &(pattrib->pktlen)); +for (j =1 ; j <=14 ; j++) { +if (ICS [i][j] !=1 ) +continue ; +if (k <16 ) { + InfoContent[k] = j;/* channel number */ +/* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } } - } + pframe =rtw_set_ie (pframe,WLAN_EID_BSS_INTOLERANT_CHL_REPORT , k, InfoContent, &(pattrib->pktlen)); + } }
@@ -3831,14 +3831,16 @@ void site_survey(struct adapter *padapter)int i;for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) { -if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { -/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ -if (padapter->registrypriv.wifi_spec) -issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); -else -issue_probereq_ex (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ,0 ,0 ,0 ,0 ); +if (!pmlmeext->sitesurvey_res.ssid[i].ssid_length) +continue ; + +/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ +if (padapter->registrypriv.wifi_spec)issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); - } +else +issue_probereq_ex (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ,0 ,0 ,0 ,0 ); + +issue_probereq (padapter, &(pmlmeext->sitesurvey_res.ssid[i]),NULL ); }if (pmlmeext->sitesurvey_res.scan_mode ==SCAN_ACTIVE ) {
Signature · 1 line
2.43.0
Re: [PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation
Quoted 3 lines · Michael Huang
Refactor nested if-statements using "continue" statements. This flattens the logic, reduces deep indentation, and improves overall code readability.
[]
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
Quoted 1 line
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-0
[]
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static void issue_action_BSSCoexistPacket(struct adapter *padapter) · line 3687
Quoted 5 lines
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0
-1@@ -3684,29 +3684,29 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter)for (i =0 ; i <8 ; i++) { -if (ICS [i][0 ] ==1 ) {
Several additional things to consider for readability
o Rename ICS to something more meaningful
o Separate the ICS[x][0] uses to another named array [8]
o Adding #defines for the array bounds 8 and 15 (or 14)
o Change the loop bounds from 1 to 0 and 15 to 14
o Converting this/these arrays to bool
o Use boolean logic
Re: [PATCH v5 1/7] staging: rtl8723bs: use continue statements to reduce indentation
Quoted 8 lines · Joe Perches
Several additional things to consider for readability
o Rename ICS to something more meaningful
o Separate the ICS[x][0] uses to another named array [8]
o Adding #defines for the array bounds 8 and 15 (or 14)
o Change the loop bounds from 1 to 0 and 15 to 14
o Converting this/these arrays to bool
o Use boolean logic
Hi Joe,
Thanks for your valuable suggestions!!!
These points—especially renaming ICS, using #defines for array bounds, and converting to boolean logic—would definitely improve the long-term maintainability of this driver.
However, to keep this series focused on fixing the immediate checkpatch warnings and reducing indentation as suggested by Dan, would it be acceptable to handle these larger refactoring tasks in a separate follow-up patch series?
I'd like to ensure the current cleanup (v5) is stable and correct before introducing more significant structural changes to the logic. Really appreciate your time!
Best regards,
Michael
PATCH v5 2/7 staging: rtl8723bs: refactor comments to fix the line length warning for exceeding 100 columns
In reply to Michael HuangAdjust the positioning and formatting of comments to align with the flattened code structure. This ensures comments remain relevant and clear following the logic refactoring.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5 -3
@@ -4987,7 +4987,8 @@ void linked_status_chk(struct adapter *padapter) link_count_limit =7 ;/* 16 sec */ /* Marked by Kurt 20130715 */ -/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, so we could not check rx limit that strictly. */ +/* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, */ +/* so we could not check rx limit that strictly. */ /* todo: To check why we under miracast session, rx_chk would be false */ psta =rtw_get_stainfo (pstapriv, pmlmeinfo->network.mac_address);if (psta) {
@@ -5968,9 +5969,10 @@ u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf)/* TDLS_ESTABLISHED : write RCR DATA BIT */ /* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ /* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ -/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_DONE_CH_SEN : channel sensing and report candidate channel */ /* TDLS_OFF_CH : first time set channel to off channel */ -/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set */ +/* base channel as target channel */ /* TDLS_P_OFF_CH : periodically go to off channel */ /* TDLS_P_BASE_CH : periodically go back to base channel */ /* TDLS_RS_RCR : restore RCR */
Signature · 1 line
2.43.0
PATCH v5 3/7 staging: rtl8723bs: remove unnecessary new lines
In reply to Michael HuangRemoved the unnecessary new lines
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0 -11
@@ -4971,7 +4971,6 @@ void linked_status_chk(struct adapter *padapter)struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;struct sta_priv *pstapriv = &padapter->stapriv; -if (is_client_associated_to_ap (padapter)) {/* linked infrastructure client mode */
@@ -5045,7 +5044,6 @@ void linked_status_chk(struct adapter *padapter)continue ;if (pmlmeinfo->FW_sta_info[i].rx_pkt ==sta_rx_pkts (psta)) { -if (pmlmeinfo->FW_sta_info[i].retry <3 ) { pmlmeinfo->FW_sta_info[i].retry++; }else {
@@ -5063,9 +5061,7 @@ void linked_status_chk(struct adapter *padapter) }/* set_link_timer(pmlmeext, DISCONNECT_TO); */ - } - }void survey_timer_hdl (struct timer_list *t)
@@ -5208,7 +5204,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) }return H2C_SUCCESS ; - }u8 createbss_hdl (struct adapter *padapter,u8 *pbuf)
@@ -5565,7 +5560,6 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)site_survey (padapter);return H2C_SUCCESS ; - }u8 setauth_hdl (struct adapter *padapter,unsigned char *pbuf)
@@ -5695,7 +5689,6 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)return H2C_SUCCESS ; } -u8 chk_bmc_sleepq_cmd (struct adapter *padapter) {struct cmd_obj *ph2c;
@@ -5820,12 +5813,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) pevt_priv->evt_done_cnt++; } - _abort_event_: - -return H2C_SUCCESS ; - }u8 h2c_msg_hdl (struct adapter *padapter,unsigned char *pbuf)
Signature · 1 line
2.43.0
PATCH v5 4/7 staging: rtl8723bs: Fix the line length exceeding 100 columns warning in the code
In reply to Michael HuangSplit lines that exceed the 100-character limit into multiple lines. This resolves checkpatch.pl warnings and improves the visual layout of the source code.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +30 -10
@@ -4932,7 +4932,9 @@ void _linked_info_dump(struct adapter *padapter)if (padapter->bLinkInfoDump) {if ((pmlmeinfo->state&0x03 ) ==WIFI_FW_STATION_STATE ) -rtw_hal_get_def_var (padapter,HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , &UndecoratedSmoothedPWDB); +rtw_hal_get_def_var (padapter, +HAL_DEF_UNDERCORATEDSMOOTHEDPWDB , + &UndecoratedSmoothedPWDB);for (i =0 ; i <NUM_STA ; i++) {if (pdvobj->macid[i]) {
@@ -5000,9 +5002,18 @@ void linked_status_chk(struct adapter *padapter) {if (rx_chk != _SUCCESS) {if (pmlmeext->retry ==0 ) { -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); -issue_probereq_ex (padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address,0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); +issue_probereq_ex (padapter, + &pmlmeinfo->network.ssid, + pmlmeinfo->network.mac_address, +0 ,0 ,0 ,0 ); } }
@@ -5507,8 +5518,11 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf)for (i =0 ; i <RTW_SSID_SCAN_AMOUNT ; i++) {if (pparm->ssid[i].ssid_length) { -memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, pparm->ssid[i].ssid,IW_ESSID_MAX_SIZE ); - pmlmeext->sitesurvey_res.ssid[i].ssid_length = pparm->ssid[i].ssid_length; +memcpy (pmlmeext->sitesurvey_res.ssid[i].ssid, + pparm->ssid[i].ssid, +IW_ESSID_MAX_SIZE ); + pmlmeext->sitesurvey_res.ssid[i].ssid_length = + pparm->ssid[i].ssid_length; }else { pmlmeext->sitesurvey_res.ssid[i].ssid_length =0 ; }
@@ -5536,7 +5550,8 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) } } -if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) { +if ((pmlmeext->sitesurvey_res.state ==SCAN_START ) || + (pmlmeext->sitesurvey_res.state ==SCAN_TXNULL )) {/* disable dynamic functions, such as high power, DIG */ Save_DM_Func_Flag (padapter);Switch_DM_Func (padapter,DYNAMIC_FUNC_DISABLE , false);
@@ -5799,7 +5814,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)/* checking if event size match the event parm size */ if ((wlanevents[evt_code].parmsize !=0 ) && - (wlanevents[evt_code].parmsize != evt_sz)) + (wlanevents[evt_code].parmsize != evt_sz)) goto _abort_event_;atomic_inc (&pevt_priv->event_seq);
@@ -5937,8 +5952,13 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; - pmlmeext->max_chan_nums =init_channel_set (padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); -init_channel_list (padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + pmlmeext->max_chan_nums =init_channel_set (padapter, + setChannelPlan_param->channel_plan, + pmlmeext->channel_set); +init_channel_list (padapter, + pmlmeext->channel_set, + pmlmeext->max_chan_nums, + &pmlmeext->channel_list);if (padapter->rtw_wdev && padapter->rtw_wdev->wiphy) {struct regulatory_request request;
Signature · 1 line
2.43.0
PATCH v5 5/7 staging: rtl8723bs: add missing space around operators
In reply to Michael HuangAdd required spaces around logical and assignment operators.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +7 -7
@@ -5037,7 +5037,7 @@ void linked_status_chk(struct adapter *padapter) }if (tx_chk == _FAIL) { - pmlmeinfo->link_count %= (link_count_limit+1 ); + pmlmeinfo->link_count %= (link_count_limit +1 ); }else { pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; pmlmeinfo->link_count =0 ;
@@ -5196,7 +5196,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) type = _HW_STATE_AP_;/* start_ap_mode(padapter); */ }else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT (0 )|BIT (1 ));/* clear state */ + pmlmeinfo->state &= ~(BIT (0 ) |BIT (1 ));/* clear state */ pmlmeinfo->state |=WIFI_FW_STATION_STATE ;/* set to STATION_STATE */ type = _HW_STATE_STATION_; }else if (psetop->mode == Ndis802_11IBSS) {
@@ -5749,8 +5749,8 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)memcpy (&(ptxBeacon_parm->network), &(pmlmeinfo->network),sizeof (struct wlan_bssid_ex )); - len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.ie_length-_BEACON_IE_OFFSET_, + len_diff =update_hidden_ssid (ptxBeacon_parm->network.ies + _BEACON_IE_OFFSET_, + ptxBeacon_parm->network.ie_length - _BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.ie_length += len_diff;
@@ -5805,8 +5805,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff ); - evt_code = (u8)((*peventbuf>>16 )&0xff ); + evt_sz = (u16)(*peventbuf &0xffff ); + evt_code = (u8)((*peventbuf >>16 ) &0xff );/* checking if event code is valid */ if (evt_code >=MAX_C2HEVT )
@@ -5853,7 +5853,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf)if (!psta_bmc)return H2C_SUCCESS ; -if ((pstapriv->tim_bitmap&BIT (0 )) && (psta_bmc->sleepq_len >0 )) { +if ((pstapriv->tim_bitmap &BIT (0 )) && (psta_bmc->sleepq_len >0 )) {msleep (10 );/* 10ms, ATIM(HIQ) Windows */ /* spin_lock_bh(&psta_bmc->sleep_q.lock); */
Signature · 1 line
2.43.0
PATCH v5 6/7 staging: rtl8723bs: remove unnecessary braces
In reply to Michael HuangRemove braces from single-line conditional statements.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +2 -3
@@ -1120,11 +1120,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->flags &= ~(WLAN_STA_WPS |WLAN_STA_MAYBE_WPS );if (!wpa_ie) { -if (elems.wps_ie) { +if (elems.wps_ie) pstat->flags |=WLAN_STA_WPS ; - }else { +else pstat->flags |=WLAN_STA_MAYBE_WPS ; - }/* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */
Signature · 1 line
2.43.0
PATCH v5 7/7 staging: rtl8723bs: use !ptr instead of ptr == NULL
In reply to Michael HuangSimplify pointer null checks by using the "!ptr" convention instead of the more verbose "ptr == NULL" comparison.
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -2
@@ -5994,8 +5994,7 @@ u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf) {struct RunInThread_param *p; - -if (pbuf ==NULL ) +if (!pbuf)return H2C_PARAMETERS_ERROR ; p = (struct RunInThread_param *)pbuf;
Signature · 1 line
2.43.0
Re: [PATCH v5 0/7] staging: rtl8723bs: cleanup and refactorcleanup and indentation refactoring
In reply to Michael HuangQuoted 19 lines · Michael Huang
This series refactors the function in
rtw_mlme_ext.cto improve readability and comply with Linux kernel coding standards.Following feedback from Dan Carpenter, this version (v5) deconstructs the previous changes into seven atomic patches. This separation ensures that logical changes (such as flattening nested loops) are isolated from purely stylistic cleanups (such as fixing indentation or NULL checks), making the review process more straightforward and less error-prone.
Each patch focuses on a single category of improvement:
1. Logic flattening: Use continue statements to reduce indentation.
2. Comment positioning: Adjust comments to align with new logic.
3. New lines cleanup: Removed unnecessary new lines
4. Line length compliance: Resolve 100-column limit warnings.
5. Operator spacing: Add missing spaces around logical operators.
6. Braces removal: Clean up unnecessary braces in single-line branches.
7. NULL check simplification: Use the "!ptr" convention for brevity.
Quoted 7 lines
---
Changes in v5:
- Split the series into 7 atomic patches for easier review.
- Renamed "guard clauses" to "continue statements" description per feedback.
- Separated logic changes, comment refactoring, and style cleanups.
- Fixed indentation issues (replaced spaces with tabs).
- Simplified NULL pointer checks to use the !ptr convention.
Thanks!
regards,
dan carpenter