Skip to contentSkip to conversation

staging: r8188eu: some error logic cleanups

PATCH In review Michael Straube 2 participants 6 messages Jan 15, 2023 – Jan 16, 2023 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: some error logic cleanups

This series converts some more functions away from returning _SUCCESS and _FAIL.

Tested on x86_64 with Inter-Tech DMG-02.

Michael Straube (4):
staging: r8188eu: convert PHY_MACConfig8188E() to common error logic
staging: r8188eu: convert phy_RF6052_Config_ParaFile() to common error
logic
staging: r8188eu: convert phy_BB8188E_Config_ParaFile() to common
error logic
staging: r8188eu: convert PHY_BBConfig8188E() to common error logic

 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 35 ++++++++++---------
 drivers/staging/r8188eu/hal/rtl8188e_rf6052.c |  7 ++--
 drivers/staging/r8188eu/hal/usb_halinit.c     | 15 ++++----
 3 files changed, 27 insertions(+), 30 deletions(-)
Signature · 1 line
2.39.0
#1 lore raw

PATCH 1/4 staging: r8188eu: convert PHY_MACConfig8188E() to common error logic

Convert the function PHY_MACConfig8188E() away from returning _FAIL or _SUCCESS which uses inverted error logic. Use the common error logic instead. Return 0 for success and negative values for failure.

---
 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 9 ++++-----
 drivers/staging/r8188eu/hal/usb_halinit.c     | 5 ++---
 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +4 -5
index b7f3c7a670fb..204c1c30377b 100644
@@ -315,21 +315,20 @@ rtl8188e_PHY_SetRFReg(
  *  08/12/2008	MHC		Create Version 0.
  *
  *---------------------------------------------------------------------------*/
-s32 PHY_MACConfig8188E(struct adapter *Adapter)
+int PHY_MACConfig8188E(struct adapter *Adapter)
 {
 	struct hal_data_8188e *pHalData = &Adapter->haldata;
-	int rtStatus = _SUCCESS;
+	int err;
 
 	/*  */
 	/*  Config MAC */
 	/*  */
-	if (ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv))
-		rtStatus = _FAIL;
+	err = ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv);
 
 	/*  2010.07.13 AMPDU aggregation number B */
 	rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM);
 
-	return rtStatus;
+	return err;
 }
 
 /**
drivers/staging/r8188eu/hal/usb_halinit.c +2 -3
index d28b4dc2a767..9ba6a526e90d 100644
@@ -600,9 +600,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)
 	Adapter->pwrctrlpriv.bFwCurrentInPSMode = false;
 	haldata->LastHMEBoxNum = 0;
 
-	status = PHY_MACConfig8188E(Adapter);
-	if (status == _FAIL)
-		goto exit;
+	if (PHY_MACConfig8188E(Adapter))
+		return _FAIL;
 
 	/*  */
 	/* d. Initialize BB related configurations. */
Signature · 1 line
2.39.0
#2 lore raw

PATCH 2/4 staging: r8188eu: convert phy_RF6052_Config_ParaFile() to common error logic

In reply to Michael Straube

Convert the function phy_RF6052_Config_ParaFile() away from returning _FAIL or _SUCCESS which uses inverted error logic. Use the common error logic instead. Return 0 for success and negative values for failure.

---
 drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 7 +++----
 drivers/staging/r8188eu/hal/usb_halinit.c     | 5 ++---
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +3 -4
index e5ec6e563fbd..1988fb6e780a 100644
@@ -371,7 +371,7 @@ int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
 	struct bb_reg_def *pPhyReg;
 	struct hal_data_8188e *pHalData = &Adapter->haldata;
 	u32 u4RegValue = 0;
-	int rtStatus = _SUCCESS;
+	int err;
 
 	/* Initialize RF */
 
@@ -396,11 +396,10 @@ int phy_RF6052_Config_ParaFile(struct adapter *Adapter)
 	udelay(1);/* PlatformStallExecution(1); */
 
 	/*----Initialize RF fom connfiguration file----*/
-	if (ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv))
-		rtStatus = _FAIL;
+	err = ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv);
 
 	/*----Restore RFENV control type----*/;
 	rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
 
-	return rtStatus;
+	return err;
 }
drivers/staging/r8188eu/hal/usb_halinit.c +2 -3
index 9ba6a526e90d..cb36b42c5ecc 100644
@@ -610,9 +610,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)
 	if (status == _FAIL)
 		goto exit;
 
-	status = phy_RF6052_Config_ParaFile(Adapter);
-	if (status == _FAIL)
-		goto exit;
+	if (phy_RF6052_Config_ParaFile(Adapter))
+		return _FAIL;
 
 	status = rtl8188e_iol_efuse_patch(Adapter);
 	if (status == _FAIL)
Signature · 1 line
2.39.0
#3 lore raw

PATCH 3/4 staging: r8188eu: convert phy_BB8188E_Config_ParaFile() to common error logic

In reply to Michael Straube

Convert the fubction phy_BB8188E_Config_ParaFile() away from returning _FAIL or _SUCCESS which uses inverted error logic. Use the common error logic instead. Return 0 for success and negative values for failure.

---
 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +10 -6
index 204c1c30377b..c52af93f1669 100644
@@ -449,13 +449,15 @@ static	int phy_BB8188E_Config_ParaFile(struct adapter *Adapter)
 {
 	struct eeprom_priv *pEEPROM = &Adapter->eeprompriv;
 	struct hal_data_8188e *pHalData = &Adapter->haldata;
+	int err;
 
 	/*  */
 	/*  1. Read PHY_REG.TXT BB INIT!! */
 	/*  We will separate as 88C / 92C according to chip version */
 	/*  */
-	if (ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv))
-		return _FAIL;
+	err = ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv);
+	if (err)
+		return err;
 
 	/*  2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */
 	if (!pEEPROM->bautoload_fail_flag) {
@@ -464,10 +466,11 @@ static	int phy_BB8188E_Config_ParaFile(struct adapter *Adapter)
 	}
 
 	/*  3. BB AGC table Initialization */
-	if (ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv))
-		return _FAIL;
+	err = ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv);
+	if (err)
+		return err;
 
-	return _SUCCESS;
+	return 0;
 }
 
 int
@@ -497,7 +500,8 @@ PHY_BBConfig8188E(
 	rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB);
 
 	/*  Config BB and AGC */
-	rtStatus = phy_BB8188E_Config_ParaFile(Adapter);
+	if (phy_BB8188E_Config_ParaFile(Adapter))
+		rtStatus = _FAIL;
 
 	/*  write 0x24[16:11] = 0x24[22:17] = CrystalCap */
 	CrystalCap = pHalData->CrystalCap & 0x3F;
Signature · 1 line
2.39.0
#4 lore raw

PATCH 4/4 staging: r8188eu: convert PHY_BBConfig8188E() to common error logic

In reply to Michael Straube

Convert the function PHY_BBConfig8188E() away from returning _FAIL or _SUCCESS which uses inverted error logic. Use the common error logic instead. Return 0 for success and negative values for failure.

---
 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 14 ++++++--------
 drivers/staging/r8188eu/hal/usb_halinit.c     |  5 ++---
 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +6 -8
index c52af93f1669..f4edf4a8f5c2 100644
@@ -478,18 +478,17 @@ PHY_BBConfig8188E(
 		struct adapter *Adapter
 	)
 {
-	int	rtStatus = _SUCCESS;
 	struct hal_data_8188e *pHalData = &Adapter->haldata;
 	u16 RegVal;
 	u8 CrystalCap;
-	int res;
+	int err;
 
 	phy_InitBBRFRegisterDefinition(Adapter);
 
 	/*  Enable BB and RF */
-	res = rtw_read16(Adapter, REG_SYS_FUNC_EN, &RegVal);
-	if (res)
-		return _FAIL;
+	err = rtw_read16(Adapter, REG_SYS_FUNC_EN, &RegVal);
+	if (err)
+		return err;
 
 	rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal | BIT(13) | BIT(0) | BIT(1)));
 
@@ -500,14 +499,13 @@ PHY_BBConfig8188E(
 	rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB);
 
 	/*  Config BB and AGC */
-	if (phy_BB8188E_Config_ParaFile(Adapter))
-		rtStatus = _FAIL;
+	err = phy_BB8188E_Config_ParaFile(Adapter);
 
 	/*  write 0x24[16:11] = 0x24[22:17] = CrystalCap */
 	CrystalCap = pHalData->CrystalCap & 0x3F;
 	rtl8188e_PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6)));
 
-	return rtStatus;
+	return err;
 }
 
 static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel,
drivers/staging/r8188eu/hal/usb_halinit.c +2 -3
index cb36b42c5ecc..b7c9e5fd9a59 100644
@@ -606,9 +606,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)
 	/*  */
 	/* d. Initialize BB related configurations. */
 	/*  */
-	status = PHY_BBConfig8188E(Adapter);
-	if (status == _FAIL)
-		goto exit;
+	if (PHY_BBConfig8188E(Adapter))
+		return _FAIL;
 
 	if (phy_RF6052_Config_ParaFile(Adapter))
 		return _FAIL;
Signature · 1 line
2.39.0
Tested-by on the v1 series
#5 lore raw
In reply to Michael Straube
Quoted 13 lines · Michael Straube

This series converts some more functions away from returning _SUCCESS and _FAIL.

Tested on x86_64 with Inter-Tech DMG-02.

Michael Straube (4):
staging: r8188eu: convert PHY_MACConfig8188E() to common error logic
staging: r8188eu: convert phy_RF6052_Config_ParaFile() to common error
logic
staging: r8188eu: convert phy_BB8188E_Config_ParaFile() to common
error logic
staging: r8188eu: convert PHY_BBConfig8188E() to common error logic

Quoted 5 lines
  drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 35 ++++++++++---------
  drivers/staging/r8188eu/hal/rtl8188e_rf6052.c |  7 ++--
  drivers/staging/r8188eu/hal/usb_halinit.c     | 15 ++++----
  3 files changed, 27 insertions(+), 30 deletions(-)