2023-01-15 21:30:08

by Michael Straube

[permalink] [raw]
Subject: [PATCH 0/4] 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(-)

--
2.39.0


2023-01-15 21:30:57

by Michael Straube

[permalink] [raw]
Subject: [PATCH 3/4] staging: r8188eu: convert phy_BB8188E_Config_ParaFile() to common error logic

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.

Signed-off-by: Michael Straube <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
index 204c1c30377b..c52af93f1669 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
@@ -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;
--
2.39.0

2023-01-15 21:38:57

by Michael Straube

[permalink] [raw]
Subject: [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.

Signed-off-by: Michael Straube <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 9 ++++-----
drivers/staging/r8188eu/hal/usb_halinit.c | 5 ++---
2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
index b7f3c7a670fb..204c1c30377b 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
@@ -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;
}

/**
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index d28b4dc2a767..9ba6a526e90d 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -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. */
--
2.39.0

2023-01-15 22:17:14

by Michael Straube

[permalink] [raw]
Subject: [PATCH 2/4] staging: r8188eu: convert phy_RF6052_Config_ParaFile() to common error logic

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.

Signed-off-by: Michael Straube <[email protected]>
---
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 7 +++----
drivers/staging/r8188eu/hal/usb_halinit.c | 5 ++---
2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
index e5ec6e563fbd..1988fb6e780a 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c
@@ -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;
}
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 9ba6a526e90d..cb36b42c5ecc 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -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)
--
2.39.0

2023-01-16 20:15:19

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH 0/4] staging: r8188eu: some error logic cleanups

On 1/15/23 22:07, Michael Straube wrote:
> 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(-)
>

Tested-by: Philipp Hortmann <[email protected]> # Edimax N150