Skip to contentSkip to conversation

staging: rtl8723bs: simplify the phy_RF6052_Config_ParaFile() function

PATCH New Nikolay Kulikov 1 participant 3 messages Jun 21 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8723bs: simplify the phy_RF6052_Config_ParaFile() function

Siplify the function by removing the loop and unreachable switch-case statements.

Nikolay Kulikov (2):
staging: rtl8723bs: remove 'NumTotalRFPath' from 'struct hal_com_data'
staging: rtl8723bs: remove local variable 'eRFPath'

 .../staging/rtl8723bs/hal/rtl8723b_rf6052.c   | 83 ++++++-------------
 drivers/staging/rtl8723bs/include/hal_data.h  |  2 -
 2 files changed, 26 insertions(+), 59 deletions(-)

base-commit: 7cb1c5b32a2bfde961fff8d5204526b609bcb30a

Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 staging: rtl8723bs: remove 'NumTotalRFPath' from 'struct hal_com_data'

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.

---
 .../staging/rtl8723bs/hal/rtl8723b_rf6052.c   | 102 ++++++++----------
 drivers/staging/rtl8723bs/include/hal_data.h  |   2 -
 2 files changed, 46 insertions(+), 58 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +46 -56
index da4cb28276b2..86759516838b 100644
@@ -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 */
 	/*  */
drivers/staging/rtl8723bs/include/hal_data.h +0 -2
index 3a93ac312ded..5796e477dcb5 100644
@@ -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__ */
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 staging: rtl8723bs: remove local variable 'eRFPath'

In reply to 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.

---
 .../staging/rtl8723bs/hal/rtl8723b_rf6052.c   | 29 +++----------------
 1 file changed, 4 insertions(+), 25 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +4 -25
index 86759516838b..fac1270853de 100644
@@ -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 */
Signature · 1 line
2.54.0