* [PATCH 1/2] staging: rtl8723bs: remove 'NumTotalRFPath' from 'struct hal_com_data'
2026-06-21 16:12 [PATCH 0/2] staging: rtl8723bs: simplify the phy_RF6052_Config_ParaFile() function Nikolay Kulikov
@ 2026-06-21 16:12 ` Nikolay Kulikov
2026-06-21 16:12 ` [PATCH 2/2] staging: rtl8723bs: remove local variable 'eRFPath' Nikolay Kulikov
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Kulikov @ 2026-06-21 16:12 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov
This variable is assigned the value 1, after which it is used as a loop
delimiter. Since it always stores 1, only one loop iteration is
performed. We can remove the 'NumTotalRFPath' field and remove the loop
by calling its body directly to simplify the code.
Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
.../staging/rtl8723bs/hal/rtl8723b_rf6052.c | 102 ++++++++----------
drivers/staging/rtl8723bs/include/hal_data.h | 2 -
2 files changed, 46 insertions(+), 58 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
index da4cb28276b2..86759516838b 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
@@ -81,61 +81,58 @@ void PHY_RF6052SetBandwidth8723B(
static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
{
u32 u4RegValue = 0;
- u8 eRFPath;
+ u8 eRFPath = 0;
struct bb_register_def *pPhyReg;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
/* 3----------------------------------------------------------------- */
/* 3 <2> Initialize RF */
/* 3----------------------------------------------------------------- */
- /* for (eRFPath = RF_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++) */
- for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) {
-
- pPhyReg = &pHalData->PHYRegDef[eRFPath];
-
- /*----Store original RFENV control type----*/
- switch (eRFPath) {
- case RF_PATH_A:
- u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
- break;
- case RF_PATH_B:
- u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16);
- break;
- }
-
- /*----Set RF_ENV enable----*/
- PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
- udelay(1);/* PlatformStallExecution(1); */
-
- /*----Set RF_ENV output high----*/
- PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
- udelay(1);/* PlatformStallExecution(1); */
-
- /* Set bit number of Address and Data for RF register */
- PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */
- udelay(1);/* PlatformStallExecution(1); */
-
- PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */
- udelay(1);/* PlatformStallExecution(1); */
-
- /*----Initialize RF fom connfiguration file----*/
- switch (eRFPath) {
- case RF_PATH_A:
- case RF_PATH_B:
- ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
- CONFIG_RF_RADIO, eRFPath);
- break;
- }
-
- /*----Restore RFENV control type----*/
- switch (eRFPath) {
- case RF_PATH_A:
- PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
- break;
- case RF_PATH_B:
- PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue);
- break;
- }
+
+ pPhyReg = &pHalData->PHYRegDef[eRFPath];
+
+ /*----Store original RFENV control type----*/
+ switch (eRFPath) {
+ case RF_PATH_A:
+ u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
+ break;
+ case RF_PATH_B:
+ u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16);
+ break;
+ }
+
+ /*----Set RF_ENV enable----*/
+ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
+ udelay(1);/* PlatformStallExecution(1); */
+
+ /*----Set RF_ENV output high----*/
+ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
+ udelay(1);/* PlatformStallExecution(1); */
+
+ /* Set bit number of Address and Data for RF register */
+ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */
+ udelay(1);/* PlatformStallExecution(1); */
+
+ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */
+ udelay(1);/* PlatformStallExecution(1); */
+
+ /*----Initialize RF fom connfiguration file----*/
+ switch (eRFPath) {
+ case RF_PATH_A:
+ case RF_PATH_B:
+ ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
+ CONFIG_RF_RADIO, eRFPath);
+ break;
+ }
+
+ /*----Restore RFENV control type----*/
+ switch (eRFPath) {
+ case RF_PATH_A:
+ PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
+ break;
+ case RF_PATH_B:
+ PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue);
+ break;
}
/* 3 ----------------------------------------------------------------- */
@@ -149,13 +146,6 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
int PHY_RF6052_Config8723B(struct adapter *Adapter)
{
- struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-
- /* */
- /* Initialize general global value */
- /* */
- pHalData->NumTotalRFPath = 1;
-
/* */
/* Config BB and RF */
/* */
diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h
index 3a93ac312ded..5796e477dcb5 100644
--- a/drivers/staging/rtl8723bs/include/hal_data.h
+++ b/drivers/staging/rtl8723bs/include/hal_data.h
@@ -187,7 +187,6 @@ struct hal_com_data {
/* rf_ctrl */
u8 rf_chip;
u8 PackageType;
- u8 NumTotalRFPath;
u8 InterfaceSel;
u8 framesync;
@@ -392,7 +391,6 @@ struct hal_com_data {
};
#define GET_HAL_DATA(__padapter) ((struct hal_com_data *)((__padapter)->HalData))
-#define GET_HAL_RFPATH_NUM(__padapter) (((struct hal_com_data *)((__padapter)->HalData))->NumTotalRFPath)
#define RT_GetInterfaceSelection(_Adapter) (GET_HAL_DATA(_Adapter)->InterfaceSel)
#endif /* __HAL_DATA_H__ */
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] staging: rtl8723bs: remove local variable 'eRFPath'
2026-06-21 16:12 [PATCH 0/2] staging: rtl8723bs: simplify the phy_RF6052_Config_ParaFile() function Nikolay Kulikov
2026-06-21 16:12 ` [PATCH 1/2] staging: rtl8723bs: remove 'NumTotalRFPath' from 'struct hal_com_data' Nikolay Kulikov
@ 2026-06-21 16:12 ` Nikolay Kulikov
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Kulikov @ 2026-06-21 16:12 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-staging, Nikolay Kulikov
After removing the loop from the phy_RF6052_Config_ParaFile() function,
the value of this variable can no longer be changed, allowing all
switch-case statements to be known in advance, since it stores the value
0 (which is 'RF_PATH_A', defined in enum rf_path).
Therefore, remove it and the associated dead code and access 'RF_PATH_A'
directly.
Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
.../staging/rtl8723bs/hal/rtl8723b_rf6052.c | 29 +++----------------
1 file changed, 4 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
index 86759516838b..fac1270853de 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c
@@ -81,7 +81,6 @@ void PHY_RF6052SetBandwidth8723B(
static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
{
u32 u4RegValue = 0;
- u8 eRFPath = 0;
struct bb_register_def *pPhyReg;
struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
@@ -89,17 +88,10 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
/* 3 <2> Initialize RF */
/* 3----------------------------------------------------------------- */
- pPhyReg = &pHalData->PHYRegDef[eRFPath];
+ pPhyReg = &pHalData->PHYRegDef[RF_PATH_A];
/*----Store original RFENV control type----*/
- switch (eRFPath) {
- case RF_PATH_A:
- u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
- break;
- case RF_PATH_B:
- u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16);
- break;
- }
+ u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV);
/*----Set RF_ENV enable----*/
PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1);
@@ -117,23 +109,10 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
udelay(1);/* PlatformStallExecution(1); */
/*----Initialize RF fom connfiguration file----*/
- switch (eRFPath) {
- case RF_PATH_A:
- case RF_PATH_B:
- ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv,
- CONFIG_RF_RADIO, eRFPath);
- break;
- }
+ ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, RF_PATH_A);
/*----Restore RFENV control type----*/
- switch (eRFPath) {
- case RF_PATH_A:
- PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
- break;
- case RF_PATH_B:
- PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue);
- break;
- }
+ PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
/* 3 ----------------------------------------------------------------- */
/* 3 Configuration of Tx Power Tracking */
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread