Skip to contentSkip to conversation

staging: rtl8723bs: refactor issue_probereq() into a single function

PATCH New Leonardo Martins Martins 1 participant 5 messages Sep 3 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8723bs: refactor issue_probereq() into a single function

This series cleans up dead code and removes invariant function parameters from the functions issue_probereq(), issue_probereq_ex() and _issue_probereq() and then merges them into a single function, making it easier to understand what the difference between function calls is.

Compile tested only.

---
Leonardo Martins Martins (4):
staging: rtl8723bs: remove invariant parameters from issue_probereq_ex()
staging: rtl8723bs: change issue_probereq return types to void
staging: rtl8723bs: remove invariant parameters from _issue_probereq()
staging: rtl8723bs: coalesce issue_probereq functions into a single one

 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c    | 98 +++++++-----------------
 drivers/staging/rtl8723bs/include/rtw_mlme_ext.h |  2 -
 2 files changed, 27 insertions(+), 73 deletions(-)

---
base-commit: 758be99c46265b74476d5e1173d781abe325533e
change-id: 20260902-issue_probereq-bdfcc4f22270

Best regards,

Signature · 1 line
Leonardo Martins Martins <[email protected]>
#1 lore raw

PATCH 1/4 staging: rtl8723bs: remove invariant parameters from issue_probereq_ex()

The parameters ch, append_wps, try_cnt and wait_ms are 0 in all usages of issue_probereq_ex(), remove them. With try_cnt always being 0, the condition (i < try_cnt) is always false, so the do-while statement is redundant and the msleep() call is unreachable, (wait_ms > 0) is also always false, and without the do-while and msleep() the conditional break is also redundant, remove all this dead code.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c    | 33 +++++++-----------------
 drivers/staging/rtl8723bs/include/rtw_mlme_ext.h |  2 +-
 2 files changed, 10 insertions(+), 25 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +9 -24
index 0c00be09fbf346aeff82be31aae801ae9265a9b0..4bdd2ae24d274cdc4b2c6496f385856c6039c55c 100644
@@ -2499,25 +2499,11 @@ inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
 	_issue_probereq(padapter, pssid, da, 0, 1, false);
 }
 
-int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, u8 ch, bool append_wps,
-	int try_cnt, int wait_ms)
+int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
 {
 	int ret;
-	int i = 0;
-
-	do {
-		ret = _issue_probereq(padapter, pssid, da, ch, append_wps,
-				      wait_ms > 0);
 
-		i++;
-
-		if (padapter->driver_stopped || padapter->bSurpriseRemoved)
-			break;
-
-		if (i < try_cnt && wait_ms > 0 && ret == _FAIL)
-			msleep(wait_ms);
-
-	} while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0)));
+	ret = _issue_probereq(padapter, pssid, da, 0, 0, false);
 
 	if (ret != _FAIL) {
 		ret = _SUCCESS;
@@ -3768,7 +3754,9 @@ void site_survey(struct adapter *padapter)
 					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_ex(padapter,
+								  &pmlmeext->sitesurvey_res.ssid[i],
+								  NULL);
 
 					issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL);
 				}
@@ -3778,7 +3766,7 @@ void site_survey(struct adapter *padapter)
 					if (padapter->registrypriv.wifi_spec)
 						issue_probereq(padapter, NULL, NULL);
 					else
-						issue_probereq_ex(padapter, NULL, NULL, 0, 0, 0, 0);
+						issue_probereq_ex(padapter, NULL, NULL);
 					issue_probereq(padapter, NULL, NULL);
 				}
 			}
@@ -4899,16 +4887,13 @@ void linked_status_chk(struct adapter *padapter)
 					if (pmlmeext->retry == 0) {
 						issue_probereq_ex(padapter,
 								  &pmlmeinfo->network.ssid,
-								  pmlmeinfo->network.mac_address,
-								  0, 0, 0, 0);
+								  pmlmeinfo->network.mac_address);
 						issue_probereq_ex(padapter,
 								  &pmlmeinfo->network.ssid,
-								  pmlmeinfo->network.mac_address,
-								  0, 0, 0, 0);
+								  pmlmeinfo->network.mac_address);
 						issue_probereq_ex(padapter,
 								  &pmlmeinfo->network.ssid,
-								  pmlmeinfo->network.mac_address,
-								  0, 0, 0, 0);
+								  pmlmeinfo->network.mac_address);
 					}
 				}
 
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +1 -1
index 70fb161afd09efc197e3f59c72972d9a611cbf01..acea9cef7756e158c7ab9e357a06a7aab300943f 100644
@@ -542,7 +542,7 @@ void issue_assocreq(struct adapter *padapter);
 void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
 void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
-s32 issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, u8 ch, bool append_wps, int try_cnt, int wait_ms);
+s32 issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
 int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/4 staging: rtl8723bs: change issue_probereq return types to void

In reply to Leonardo Martins Martins

The return values of issue_probereq_ex() and _issue_probereq() are never used anywhere, change their return types to void to reflect this.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c    | 31 ++++++------------------
 drivers/staging/rtl8723bs/include/rtw_mlme_ext.h |  2 +-
 2 files changed, 8 insertions(+), 25 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +7 -24
index 4bdd2ae24d274cdc4b2c6496f385856c6039c55c..d3c87d25fab1108adde15d959e0b890b2180f20d 100644
@@ -2401,11 +2401,10 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 	dump_mgntframe(padapter, pmgntframe);
 }
 
-static int _issue_probereq(struct adapter *padapter,
-			   struct ndis_802_11_ssid *pssid,
-			   u8 *da, u8 ch, bool append_wps, bool wait_ack)
+static void _issue_probereq(struct adapter *padapter,
+			    struct ndis_802_11_ssid *pssid,
+			    u8 *da, u8 ch, bool append_wps, bool wait_ack)
 {
-	int ret = _FAIL;
 	struct xmit_frame		*pmgntframe;
 	struct pkt_attrib		*pattrib;
 	unsigned char *pframe;
@@ -2420,7 +2419,7 @@ static int _issue_probereq(struct adapter *padapter,
 
 	pmgntframe = alloc_mgtxmitframe(pxmitpriv);
 	if (!pmgntframe)
-		goto exit;
+		return;
 
 	/* update attribute */
 	pattrib = &pmgntframe->attrib;
@@ -2484,14 +2483,10 @@ static int _issue_probereq(struct adapter *padapter,
 	pattrib->last_txcmdsz = pattrib->pktlen;
 
 	if (wait_ack) {
-		ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe);
+		dump_mgntframe_and_wait_ack(padapter, pmgntframe);
 	} else {
 		dump_mgntframe(padapter, pmgntframe);
-		ret = _SUCCESS;
 	}
-
-exit:
-	return ret;
 }
 
 inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
@@ -2499,21 +2494,9 @@ inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps
 	_issue_probereq(padapter, pssid, da, 0, 1, false);
 }
 
-int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
+void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
 {
-	int ret;
-
-	ret = _issue_probereq(padapter, pssid, da, 0, 0, false);
-
-	if (ret != _FAIL) {
-		ret = _SUCCESS;
-		#ifndef DBG_XMIT_ACK
-		goto exit;
-		#endif
-	}
-
-exit:
-	return ret;
+	_issue_probereq(padapter, pssid, da, 0, 0, false);
 }
 
 /*  if psta == NULL, indicate we are station(client) now... */
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +1 -1
index acea9cef7756e158c7ab9e357a06a7aab300943f..8e35aabb0ccf96a2bb0c1208db8ad74598a687e0 100644
@@ -542,7 +542,7 @@ void issue_assocreq(struct adapter *padapter);
 void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
 void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
-s32 issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
+void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
 int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
Signature · 1 line
2.47.3
#3 lore raw

PATCH 3/4 staging: rtl8723bs: remove invariant parameters from _issue_probereq()

In reply to Leonardo Martins Martins

The parameters ch and wait_ack in _issue_probereq() are always 0 and false respectively, remove them and remove unreachable code that depends on them not being these values.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +5 -13
index d3c87d25fab1108adde15d959e0b890b2180f20d..b3642c5021a230bd70e5d8fd8d5bf77ad1d8946a 100644
@@ -2401,9 +2401,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 	dump_mgntframe(padapter, pmgntframe);
 }
 
-static void _issue_probereq(struct adapter *padapter,
-			    struct ndis_802_11_ssid *pssid,
-			    u8 *da, u8 ch, bool append_wps, bool wait_ack)
+static void _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
+			    bool append_wps)
 {
 	struct xmit_frame		*pmgntframe;
 	struct pkt_attrib		*pattrib;
@@ -2468,9 +2467,6 @@ static void _issue_probereq(struct adapter *padapter,
 		pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen));
 	}
 
-	if (ch)
-		pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, &ch, &pattrib->pktlen);
-
 	if (append_wps) {
 		/* add wps_ie for wps2.0 */
 		if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) {
@@ -2482,21 +2478,17 @@ static void _issue_probereq(struct adapter *padapter,
 
 	pattrib->last_txcmdsz = pattrib->pktlen;
 
-	if (wait_ack) {
-		dump_mgntframe_and_wait_ack(padapter, pmgntframe);
-	} else {
-		dump_mgntframe(padapter, pmgntframe);
-	}
+	dump_mgntframe(padapter, pmgntframe);
 }
 
 inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
 {
-	_issue_probereq(padapter, pssid, da, 0, 1, false);
+	_issue_probereq(padapter, pssid, da, 1);
 }
 
 void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
 {
-	_issue_probereq(padapter, pssid, da, 0, 0, false);
+	_issue_probereq(padapter, pssid, da, 0);
 }
 
 /*  if psta == NULL, indicate we are station(client) now... */
Signature · 1 line
2.47.3
#4 lore raw

PATCH 4/4 staging: rtl8723bs: coalesce issue_probereq functions into a single one

In reply to Leonardo Martins Martins

The function _issue_probereq() and its wrappers issue_probereq() and issue_probereq_ex() have a difference of a single parameter in how they're called, which is the value of append_wps - 0 for issue_probereq_ex() and 1 for issue_probereq() - meaning that these wrappers don't bring much value, remove both of them, rename _issue_probereq() to issue_probereq(), and replace the usages of the wrappers with the unified function (with the value of append_wps added, with true and false instead of 1 and 0 since it's a bool).

issue_probereq() and issue_probereq_ex() are not used in any other file so the unified function was not added to the header file and kept the static type.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c    | 54 +++++++++++-------------
 drivers/staging/rtl8723bs/include/rtw_mlme_ext.h |  2 -
 2 files changed, 25 insertions(+), 31 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +25 -29
index b3642c5021a230bd70e5d8fd8d5bf77ad1d8946a..c39fb142302edf267edca31babce40120c74451e 100644
@@ -2401,8 +2401,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 	dump_mgntframe(padapter, pmgntframe);
 }
 
-static void _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
-			    bool append_wps)
+static void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da,
+			   bool append_wps)
 {
 	struct xmit_frame		*pmgntframe;
 	struct pkt_attrib		*pattrib;
@@ -2481,16 +2481,6 @@ static void _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *p
 	dump_mgntframe(padapter, pmgntframe);
 }
 
-inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
-{
-	_issue_probereq(padapter, pssid, da, 1);
-}
-
-void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da)
-{
-	_issue_probereq(padapter, pssid, da, 0);
-}
-
 /*  if psta == NULL, indicate we are station(client) now... */
 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status)
 {
@@ -3727,22 +3717,25 @@ void site_survey(struct adapter *padapter)
 
 					/* 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);
+						issue_probereq(padapter,
+							       &pmlmeext->sitesurvey_res.ssid[i],
+							       NULL, true);
 					else
-						issue_probereq_ex(padapter,
-								  &pmlmeext->sitesurvey_res.ssid[i],
-								  NULL);
+						issue_probereq(padapter,
+							       &pmlmeext->sitesurvey_res.ssid[i],
+							       NULL, false);
 
-					issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL);
+					issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i],
+						       NULL, true);
 				}
 
 				if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) {
 					/* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */
 					if (padapter->registrypriv.wifi_spec)
-						issue_probereq(padapter, NULL, NULL);
+						issue_probereq(padapter, NULL, NULL, true);
 					else
-						issue_probereq_ex(padapter, NULL, NULL);
-					issue_probereq(padapter, NULL, NULL);
+						issue_probereq(padapter, NULL, NULL, false);
+					issue_probereq(padapter, NULL, NULL, true);
 				}
 			}
 		}
@@ -4860,15 +4853,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);
-						issue_probereq_ex(padapter,
-								  &pmlmeinfo->network.ssid,
-								  pmlmeinfo->network.mac_address);
-						issue_probereq_ex(padapter,
-								  &pmlmeinfo->network.ssid,
-								  pmlmeinfo->network.mac_address);
+						issue_probereq(padapter,
+							       &pmlmeinfo->network.ssid,
+							       pmlmeinfo->network.mac_address,
+							       false);
+						issue_probereq(padapter,
+							       &pmlmeinfo->network.ssid,
+							       pmlmeinfo->network.mac_address,
+							       false);
+						issue_probereq(padapter,
+							       &pmlmeinfo->network.ssid,
+							       pmlmeinfo->network.mac_address,
+							       false);
 					}
 				}
 
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +0 -2
index 8e35aabb0ccf96a2bb0c1208db8ad74598a687e0..d486cd462509e9d43d43a7d6718a3bb3935df52d 100644
@@ -541,8 +541,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p
 void issue_assocreq(struct adapter *padapter);
 void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
-void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
-void issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
 int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
Signature · 1 line
2.47.3