Skip to contentSkip to conversation

staging: r8188eu: some trivial cleanups

PATCH In review Martin Kaiser 3 participants 10 messages Jan 2, 2022 – Jan 4, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: some trivial cleanups

Remove unused variables and defines in several places.

Martin Kaiser (5):
staging: r8188eu: remove unused power management defines
staging: r8188eu: internal autosuspend is always false
staging: r8188eu: fix_rate is set but not used.
staging: r8188eu: cmd_issued_cnt is set but not used
staging: r8188eu: turbo scan is always off for r8188eu

 drivers/staging/r8188eu/core/rtw_cmd.c        |  3 ---
 drivers/staging/r8188eu/core/rtw_pwrctrl.c    |  9 +-------
 drivers/staging/r8188eu/hal/rtl8188e_dm.c     |  1 -
 drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 21 +++++++------------
 drivers/staging/r8188eu/include/drv_types.h   |  2 --
 drivers/staging/r8188eu/include/rtw_cmd.h     |  1 -
 drivers/staging/r8188eu/include/rtw_pwrctrl.h |  5 -----
 drivers/staging/r8188eu/os_dep/ioctl_linux.c  |  6 ------
 drivers/staging/r8188eu/os_dep/os_intfs.c     |  4 ----
 drivers/staging/r8188eu/os_dep/usb_intf.c     |  3 +--
 10 files changed, 9 insertions(+), 46 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/5 staging: r8188eu: remove unused power management defines

Remove unused defines from enum power_mgnt.

---
 drivers/staging/r8188eu/include/rtw_pwrctrl.h | 4 ----
 1 file changed, 4 deletions(-)
drivers/staging/r8188eu/include/rtw_pwrctrl.h +0 -4
index 849e144c90dd..40032447355d 100644
@@ -19,10 +19,6 @@ enum power_mgnt {
 	PS_MODE_DTIM,
 	PS_MODE_VOIP,
 	PS_MODE_UAPSD_WMM,
-	PS_MODE_UAPSD,
-	PS_MODE_IBSS,
-	PS_MODE_WWLAN,
-	PM_Radio_Off,
 	PM_Card_Disable,
 	PS_MODE_NUM
 };
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/5 staging: r8188eu: internal autosuspend is always false

In reply to Martin Kaiser

bInternalAutoSuspend is always false. Remove the variable and related checks.

---
 drivers/staging/r8188eu/core/rtw_pwrctrl.c    | 9 +--------
 drivers/staging/r8188eu/include/rtw_pwrctrl.h | 1 -
 drivers/staging/r8188eu/os_dep/os_intfs.c     | 4 ----
 drivers/staging/r8188eu/os_dep/usb_intf.c     | 3 +--
 4 files changed, 2 insertions(+), 15 deletions(-)
drivers/staging/r8188eu/core/rtw_pwrctrl.c +1 -8
index 7fa4516af6ec..46e44aee587f 100644
@@ -351,7 +351,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
 
 	pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL;
 	pwrctrlpriv->pwr_state_check_cnts = 0;
-	pwrctrlpriv->bInternalAutoSuspend = false;
 	pwrctrlpriv->bInSuspend = false;
 	pwrctrlpriv->bkeepfwalive = false;
 
@@ -396,7 +395,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
 	}
 
 	/* System suspend is not allowed to wakeup */
-	if ((!pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) {
+	if (pwrpriv->bInSuspend) {
 		while (pwrpriv->bInSuspend &&
 		       (rtw_get_passing_time_ms(start) <= 3000 ||
 		       (rtw_get_passing_time_ms(start) <= 500)))
@@ -407,12 +406,6 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal
 			DBG_88E("%s wait bInSuspend done\n", __func__);
 	}
 
-	/* block??? */
-	if ((pwrpriv->bInternalAutoSuspend)  && (padapter->net_closed)) {
-		ret = _FAIL;
-		goto exit;
-	}
-
 	/* I think this should be check in IPS, LPS, autosuspend functions... */
 	if (check_fwstate(pmlmepriv, _FW_LINKED)) {
 		ret = _SUCCESS;
drivers/staging/r8188eu/include/rtw_pwrctrl.h +0 -1
index 40032447355d..2d5298373d74 100644
@@ -75,7 +75,6 @@ struct pwrctrl_priv {
 	s32		pnp_current_pwr_state;
 	u8		pnp_bstop_trx;
 
-	u8		bInternalAutoSuspend;
 	u8		bInSuspend;
 	u8		bSupportRemoteWakeup;
 	struct timer_list pwr_state_check_timer;
drivers/staging/r8188eu/os_dep/os_intfs.c +0 -4
index f81e26785d66..b65e44f97826 100644
@@ -760,10 +760,6 @@ int netdev_close(struct net_device *pnetdev)
 	struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
 
-	if (padapter->pwrctrlpriv.bInternalAutoSuspend) {
-		if (padapter->pwrctrlpriv.rf_pwrstate == rf_off)
-			padapter->pwrctrlpriv.ps_flag = true;
-	}
 	padapter->net_closed = true;
 
 	if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) {
drivers/staging/r8188eu/os_dep/usb_intf.c +1 -2
index 5c1faf01cb51..91792dfd3bbe 100644
@@ -192,8 +192,7 @@ static void rtw_dev_unload(struct adapter *padapter)
 		if (padapter->intf_stop)
 			padapter->intf_stop(padapter);
 		/* s4. */
-		if (!padapter->pwrctrlpriv.bInternalAutoSuspend)
-			rtw_stop_drv_threads(padapter);
+		rtw_stop_drv_threads(padapter);
 
 		/* s5. */
 		if (!padapter->bSurpriseRemoved) {
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/5 staging: r8188eu: fix_rate is set but not used.

In reply to Martin Kaiser

fix_rate in struct adapter is set but not used. Remove the variable and the private ioctl code to set it.

---
 drivers/staging/r8188eu/hal/rtl8188e_dm.c    | 1 -
 drivers/staging/r8188eu/include/drv_types.h  | 2 --
 drivers/staging/r8188eu/os_dep/ioctl_linux.c | 6 ------
 3 files changed, 9 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_dm.c +0 -1
index 685431034495..bd6eb3878060 100644
@@ -84,7 +84,6 @@ void rtl8188e_InitHalDm(struct adapter *Adapter)
 	dm_InitGPIOSetting(Adapter);
 	Update_ODM_ComInfo_88E(Adapter);
 	ODM_DMInit(dm_odm);
-	Adapter->fix_rate = 0xFF;
 }
 
 void rtl8188e_HalDmWatchDog(struct adapter *Adapter)
drivers/staging/r8188eu/include/drv_types.h +0 -2
index c586a35014d8..2dd5ebaaa921 100644
@@ -264,8 +264,6 @@ struct adapter {
 	unsigned char			br_ip[4];
 	struct br_ext_info		ethBrExtInfo;
 
-	u8	fix_rate;
-
 	unsigned char     in_cta_test;
 };
 
drivers/staging/r8188eu/os_dep/ioctl_linux.c +0 -6
index 9d277151a5ee..6e9a6d4db089 100644
@@ -3978,12 +3978,6 @@ static int rtw_dbg_port(struct net_device *dev,
 			DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off");
 			padapter->bShowGetP2PState = extra_arg;
 			break;
-		case 0xaa:
-			if (extra_arg > 0x13)
-				extra_arg = 0xFF;
-			DBG_88E("chang data rate to :0x%02x\n", extra_arg);
-			padapter->fix_rate = extra_arg;
-			break;
 		case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */
 			if (extra_arg == 0)
 				mac_reg_dump(padapter);
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/5 staging: r8188eu: cmd_issued_cnt is set but not used

In reply to Martin Kaiser

cmd_issued_cnt in struct cmd_priv is set but not used. It can be removed.

---
 drivers/staging/r8188eu/core/rtw_cmd.c    | 3 ---
 drivers/staging/r8188eu/include/rtw_cmd.h | 1 -
 2 files changed, 4 deletions(-)
drivers/staging/r8188eu/core/rtw_cmd.c +0 -3
index 6d503eb7ff26..8bfb01c2ebb5 100644
@@ -50,7 +50,6 @@ static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
 
 	pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf  +  4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3);
 
-	pcmdpriv->cmd_issued_cnt = 0;
 	pcmdpriv->cmd_done_cnt = 0;
 	pcmdpriv->rsp_cnt = 0;
 exit:
@@ -269,8 +268,6 @@ int rtw_cmd_thread(void *context)
 			goto post_process;
 		}
 
-		pcmdpriv->cmd_issued_cnt++;
-
 		pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */
 
 		memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
drivers/staging/r8188eu/include/rtw_cmd.h +0 -1
index 47c3c80cc24a..cf0945ae11c1 100644
@@ -42,7 +42,6 @@ struct cmd_priv {
 	u8	*cmd_allocated_buf;
 	u8	*rsp_buf;	/* shall be non-paged, and 4 bytes aligned */
 	u8	*rsp_allocated_buf;
-	u32	cmd_issued_cnt;
 	u32	cmd_done_cnt;
 	u32	rsp_cnt;
 	u8 cmdthd_running;
Signature · 1 line
2.30.2
#5 lore raw

PATCH 5/5 staging: r8188eu: turbo scan is always off for r8188eu

In reply to Martin Kaiser

Turbo scan is always disabled. Remove the TurboScanOff variable and related checks.

---
 drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 21 +++++++------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +7 -14
index 0b982cc7c86f..6e0231099986 100644
@@ -87,28 +87,21 @@ rtl8188e_PHY_RF6052SetCckTxPower(
 	struct hal_data_8188e *pHalData = &Adapter->haldata;
 	struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
 	u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value;
-	bool TurboScanOff = false;
 	u8 idx1, idx2;
 	u8 *ptr;
 	u8 direction;
-	/* FOR CE ,must disable turbo scan */
-	TurboScanOff = true;
 
 	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
 		TxAGC[RF_PATH_A] = 0x3f3f3f3f;
 		TxAGC[RF_PATH_B] = 0x3f3f3f3f;
 
-		TurboScanOff = true;/* disable turbo scan */
-
-		if (TurboScanOff) {
-			for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
-				TxAGC[idx1] =
-					pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
-					(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
-				/*  2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */
-				if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA)
-					TxAGC[idx1] = 0x20;
-			}
+		for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
+			TxAGC[idx1] =
+				pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
+				(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
+			/*  2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */
+			if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA)
+				TxAGC[idx1] = 0x20;
 		}
 	} else {
 		for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
Signature · 1 line
2.30.2
#6 lore raw

Re: [PATCH 5/5] staging: r8188eu: turbo scan is always off for r8188eu

Quoted 38 lines · Martin Kaiser

Turbo scan is always disabled. Remove the TurboScanOff variable and related checks.

---
  drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 21 +++++++------------
  1 file changed, 7 insertions(+), 14 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +0 -14
index 0b982cc7c86f..6e0231099986 100644
@@ -87,28 +87,21 @@ rtl8188e_PHY_RF6052SetCckTxPower(
  	struct hal_data_8188e *pHalData = &Adapter->haldata;
  	struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
  	u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value;
-	bool TurboScanOff = false;
  	u8 idx1, idx2;
  	u8 *ptr;
  	u8 direction;
-	/* FOR CE ,must disable turbo scan */
-	TurboScanOff = true;
 
  	if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {
  		TxAGC[RF_PATH_A] = 0x3f3f3f3f;
  		TxAGC[RF_PATH_B] = 0x3f3f3f3f;
 
-		TurboScanOff = true;/* disable turbo scan */
-
-		if (TurboScanOff) {
-			for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
-				TxAGC[idx1] =
-					pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
-					(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
-				/*  2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */
-				if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA)
-					TxAGC[idx1] = 0x20;
-			}

drivers/staging/r8188eu/hal/rtl8188e_rf6052.c rtl8188e_PHY_RF6052SetCckTxPower( · line 107

Quoted 10 lines
drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +7 -0
+		for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
+			TxAGC[idx1] =
+				pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) |
+				(pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24);
+			/*  2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */
+			if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA)
+				TxAGC[idx1] = 0x20;
  		}
  	} else {
  		for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {

Hi Martin,

thanks for your clean up work!

It's a bit unrelated to the patch, but I found it while reviewing this. It's in the same function rtl8188e_PHY_RF6052SetCckTxPower():

89: u32 TxAGC[2] = {0, 0};
...
92 u8 *ptr;
...
129 for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
130 ptr = (u8 *)(&TxAGC[idx1]);
131 for (idx2 = 0; idx2 < 4; idx2++) {
132 if (*ptr > RF6052_MAX_TX_PWR)
133 *ptr = RF6052_MAX_TX_PWR;
134 ptr++;
135 }
136 }

What is going on here? Code just checks and writes to random place on stack outside TxAGC array? I might be missing something, but it looks wrong...

Just wanted to share, since I believe your knowledge about this driver is much deeper than mine :)

thanks

With regards,
Pavel Skripkin

#7 lore raw

Re: [PATCH 5/5] staging: r8188eu: turbo scan is always off for r8188eu

Hi Pavel,

Thus wrote Pavel Skripkin ([email protected]):

Quoted 17 lines

It's a bit unrelated to the patch, but I found it while reviewing this. It's in the same function rtl8188e_PHY_RF6052SetCckTxPower():

89: u32 TxAGC[2] = {0, 0};
...
92 u8 *ptr;
...
129 for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
130 ptr = (u8 *)(&TxAGC[idx1]);
131 for (idx2 = 0; idx2 < 4; idx2++) {
132 if (*ptr > RF6052_MAX_TX_PWR)
133 *ptr = RF6052_MAX_TX_PWR;
134 ptr++;
135 }
136 }

Quoted 2 lines

What is going on here? Code just checks and writes to random place on stack outside TxAGC array? I might be missing something, but it looks wrong...

TxAGC is two 32-bit values, i.e. 2 x 4 Bytes. The outer loop selects a 32-bit array entry, the inner loop iterates over each byte of this entry and checks that it is <= RF6052_MAX_TX_PWR. I don't think this writes past the end of the TxAGC[] array.

The rtlwifi driver contains a similar check in
rtl92ce_phy_rf6052_set_cck_txpower().

Best regards,
Martin

#8 lore raw

Re: [PATCH 5/5] staging: r8188eu: turbo scan is always off for r8188eu

Quoted 21 lines · Martin Kaiser

Hi Pavel,

Thus wrote Pavel Skripkin ([email protected]):

Quoted 15 lines

It's a bit unrelated to the patch, but I found it while reviewing this. It's in the same function rtl8188e_PHY_RF6052SetCckTxPower():

89: u32 TxAGC[2] = {0, 0};
...
92 u8 *ptr;
...
129 for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) {
130 ptr = (u8 *)(&TxAGC[idx1]);
131 for (idx2 = 0; idx2 < 4; idx2++) {
132 if (*ptr > RF6052_MAX_TX_PWR)
133 *ptr = RF6052_MAX_TX_PWR;
134 ptr++;
135 }
136 }

Quoted 8 lines
Quoted 2 lines

What is going on here? Code just checks and writes to random place on stack outside TxAGC array? I might be missing something, but it looks wrong...

TxAGC is two 32-bit values, i.e. 2 x 4 Bytes. The outer loop selects a 32-bit array entry, the inner loop iterates over each byte of this entry and checks that it is <= RF6052_MAX_TX_PWR. I don't think this writes past the end of the TxAGC[] array.

Oh.... I should have go to sleep earlier that evening, sorry. I've missed, that this array is u32, but not u8.

Sorry for that noise :(

With regards,
Pavel Skripkin

Acked-by on the v1 series
#9 lore raw
In reply to Martin Kaiser
Quoted 9 lines · Martin Kaiser

Remove unused variables and defines in several places.

Martin Kaiser (5):
staging: r8188eu: remove unused power management defines
staging: r8188eu: internal autosuspend is always false
staging: r8188eu: fix_rate is set but not used.
staging: r8188eu: cmd_issued_cnt is set but not used
staging: r8188eu: turbo scan is always off for r8188eu

Quoted 12 lines
  drivers/staging/r8188eu/core/rtw_cmd.c        |  3 ---
  drivers/staging/r8188eu/core/rtw_pwrctrl.c    |  9 +-------
  drivers/staging/r8188eu/hal/rtl8188e_dm.c     |  1 -
  drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 21 +++++++------------
  drivers/staging/r8188eu/include/drv_types.h   |  2 --
  drivers/staging/r8188eu/include/rtw_cmd.h     |  1 -
  drivers/staging/r8188eu/include/rtw_pwrctrl.h |  5 -----
  drivers/staging/r8188eu/os_dep/ioctl_linux.c  |  6 ------
  drivers/staging/r8188eu/os_dep/os_intfs.c     |  4 ----
  drivers/staging/r8188eu/os_dep/usb_intf.c     |  3 +--
  10 files changed, 9 insertions(+), 46 deletions(-)

Looks good to me. For all patches: