Skip to contentSkip to conversation

staging: rtl8723bs: Code cleanup in drivers/staging/rtl8723bs

PATCH Superseded Prithvi Tambewagh 4 participants 21 messages Apr 5 – Apr 9 Staging

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover staging: rtl8723bs: Code cleanup in drivers/staging/rtl8723bs

This patch series focuses on code cleanup in drivers/staging/rtl8723bs, majorly focusing on fixing checkpatch warnings of constant being on right side of test in comparisons, deletion of empty if block ,use of read_poll_timeout_atomic(), and other code simplifications.

v2 link: https://lore.kernel.org/linux-staging/20260403094647.fmgop6xh2cjpit3s@inspiron/T/#m3d08fd012119772e>
v1 link: https://lore.kernel.org/linux-staging/20260323145214.ubhshy2gwp52j5zh@inspiron/T/#mc3b693b37c49fbdd>

Note:
1. I found that for this change in v2:

- if (
- (false == pHalData->bDisableSWChannelPlan) &&
- rtw_is_channel_plan_valid(sw_channel_plan)
- )
+ if (!pHalData->bDisableSWChannelPlan &&
+ rtw_is_channel_plan_valid(sw_channel_plan))

for this code, checkpatch gave the check:

CHECK: Using comparison to false is error prone #126: FILE: drivers/staging/rtl8723bs/hal/hal_com.c:126:
+ (false == pHalData->bDisableSWChannelPlan) &&

which is a different logical change than the ones covered in this patch series. Hence, to keep the patch series to a reasonable length and since this is RFT path series, I did not consider this change right now.

2. This change in v2:

        if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                        txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
        } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                        txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
        }

can be reformatted as:

drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -4
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
        if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
                txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-       if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+       if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+               if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
                        txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-       } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
                        txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];

for which it is sent as a separate patch - patch 5 in this series.

3. I found, in drivers/staging/rtl8723bs/hal/odm.h:

struct odm_rate_adaptive {
u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */
u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */
bool bUseLdpc;
bool bLowerRtsRate;
u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */
u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */
u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_>

};

and based on the explanation of parameters HighRSSIThresh & LowRSSIThresh I thought this change:

drivers/staging/rtl8723bs/hal/odm.c +2 -2
index 639b6da2302b..ca4495f101fd 100644
@@ -343,9 +343,9 @@ bool ODM_RAStateCheck(
        }
 
        /*  Decide RATRState by RSSI. */
-       if (RSSI > HighRSSIThreshForRA)
+       if (HighRSSIThreshForRA < RSSI)
                RATRState = DM_RATR_STA_HIGH;
-       else if (RSSI > LowRSSIThreshForRA)
+       else if (LowRSSIThreshForRA < RSSI) 
                RATRState = DM_RATR_STA_MIDDLE;
       else
                RATRState = DM_RATR_STA_LOW;

doesn't seem to be right, thats why I dropped this change as well.

4. This patch series is compile tested using the following commands, which include setting the necessary configurations:
1. make defconfig
2. scripts/config --enable CONFIG_STAGING
3. scripts/config --module CONFIG_MMC
4. scripts/config --module CONFIG_RTL8723BS
5. make olddefconfig
6. make -j$(nproc)
7. git rebase -i --exec "make -j$(nproc) M=drivers/staging/rtl8723bs" HEAD~5

The final rebase --exec gave a successful output:

Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

  CC [M]  core/rtw_ap.o
  CC [M]  core/rtw_btcoex.o
  CC [M]  core/rtw_cmd.o
  CC [M]  core/rtw_efuse.o
  CC [M]  core/rtw_io.o
  CC [M]  core/rtw_ioctl_set.o
  CC [M]  core/rtw_ieee80211.o
  CC [M]  core/rtw_mlme.o
  CC [M]  core/rtw_mlme_ext.o
  CC [M]  core/rtw_pwrctrl.o
  CC [M]  core/rtw_recv.o
  CC [M]  core/rtw_security.o
  CC [M]  core/rtw_sta_mgt.o
  CC [M]  core/rtw_wlan_util.o
  CC [M]  core/rtw_xmit.o
  CC [M]  hal/hal_intf.o
  CC [M]  hal/hal_com.o
  CC [M]  hal/hal_com_phycfg.o
  CC [M]  hal/hal_btcoex.o
  CC [M]  hal/hal_sdio.o
  CC [M]  hal/hal_pwr_seq.o
  CC [M]  hal/HalPhyRf.o
  CC [M]  hal/HalPwrSeqCmd.o
  CC [M]  hal/odm_CfoTracking.o
  CC [M]  hal/odm.o
  CC [M]  hal/odm_DIG.o
  CC [M]  hal/odm_DynamicBBPowerSaving.o
  CC [M]  hal/odm_DynamicTxPower.o
  CC [M]  hal/odm_EdcaTurboCheck.o
  CC [M]  hal/odm_HWConfig.o
  CC [M]  hal/odm_RegConfig8723B.o
  CC [M]  hal/rtl8723b_cmd.o
  CC [M]  hal/rtl8723b_dm.o
  CC [M]  hal/rtl8723b_hal_init.o
  CC [M]  hal/rtl8723b_phycfg.o
  CC [M]  hal/rtl8723b_rf6052.o
  CC [M]  hal/rtl8723b_rxdesc.o
  CC [M]  hal/rtl8723bs_recv.o
  CC [M]  hal/rtl8723bs_xmit.o
  CC [M]  hal/sdio_halinit.o
  CC [M]  hal/sdio_ops.o
  CC [M]  hal/HalBtc8723b1Ant.o
  CC [M]  hal/HalBtc8723b2Ant.o
  CC [M]  hal/HalHWImg8723B_BB.o
  CC [M]  hal/HalHWImg8723B_MAC.o
  CC [M]  hal/HalHWImg8723B_RF.o
  CC [M]  hal/HalPhyRf_8723B.o
  CC [M]  os_dep/ioctl_cfg80211.o
  CC [M]  os_dep/osdep_service.o
  CC [M]  os_dep/os_intfs.o
  CC [M]  os_dep/sdio_intf.o
  CC [M]  os_dep/sdio_ops_linux.o
  CC [M]  os_dep/wifi_regd.o
  CC [M]  os_dep/xmit_linux.o
  LD [M]  r8723bs.o
  MODPOST Module.symvers
  CC [M]  r8723bs.mod.o
  CC [M]  .module-common.o
  LD [M]  r8723bs.ko

make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/HalPhyRf_8723B.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

  CC [M]  core/rtw_ap.o
  CC [M]  core/rtw_btcoex.o
  CC [M]  core/rtw_cmd.o
  CC [M]  core/rtw_efuse.o
  CC [M]  core/rtw_io.o
  CC [M]  core/rtw_ioctl_set.o
  CC [M]  core/rtw_ieee80211.o
  CC [M]  core/rtw_mlme.o
  CC [M]  core/rtw_mlme_ext.o
  CC [M]  core/rtw_pwrctrl.o
  CC [M]  core/rtw_recv.o
  CC [M]  core/rtw_security.o
  CC [M]  core/rtw_sta_mgt.o
  CC [M]  core/rtw_wlan_util.o
  CC [M]  core/rtw_xmit.o
  CC [M]  hal/hal_intf.o
  CC [M]  hal/hal_com.o
  CC [M]  hal/hal_com_phycfg.o
  CC [M]  hal/hal_btcoex.o
  CC [M]  hal/hal_sdio.o
  CC [M]  hal/hal_pwr_seq.o
  CC [M]  hal/HalPhyRf.o
  CC [M]  hal/HalPwrSeqCmd.o
  CC [M]  hal/odm.o
  CC [M]  hal/odm_CfoTracking.o
  CC [M]  hal/odm_DIG.o
  CC [M]  hal/odm_DynamicBBPowerSaving.o
  CC [M]  hal/odm_DynamicTxPower.o
  CC [M]  hal/odm_EdcaTurboCheck.o
  CC [M]  hal/odm_HWConfig.o
  CC [M]  hal/odm_RegConfig8723B.o
  CC [M]  hal/rtl8723b_cmd.o
  CC [M]  hal/rtl8723b_dm.o
  CC [M]  hal/rtl8723b_hal_init.o
  CC [M]  hal/rtl8723b_phycfg.o
  CC [M]  hal/rtl8723b_rf6052.o
  CC [M]  hal/rtl8723b_rxdesc.o
  CC [M]  hal/rtl8723bs_recv.o
  CC [M]  hal/rtl8723bs_xmit.o
  CC [M]  hal/sdio_halinit.o
  CC [M]  hal/sdio_ops.o
  CC [M]  hal/HalBtc8723b1Ant.o
  CC [M]  hal/HalBtc8723b2Ant.o
  CC [M]  hal/HalHWImg8723B_BB.o
  CC [M]  hal/HalHWImg8723B_MAC.o
  CC [M]  hal/HalHWImg8723B_RF.o
  CC [M]  hal/HalPhyRf_8723B.o
  CC [M]  os_dep/ioctl_cfg80211.o
  CC [M]  os_dep/osdep_service.o
  CC [M]  os_dep/os_intfs.o
  CC [M]  os_dep/sdio_intf.o
  CC [M]  os_dep/sdio_ops_linux.o
  CC [M]  os_dep/wifi_regd.o
  CC [M]  os_dep/xmit_linux.o
  LD [M]  r8723bs.o

MODPOST Module.symvers
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/rtl8723b_cmd.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/hal_com_phycfg.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs' Successfully rebased and updated refs/heads/staging-realtek-patch-series.

However, since I currently don't have rtl8723bs hardware I am unfortunately unable to do runtime testing for this patch series.

Prithvi Tambewagh (5):
staging: rtl8723bs: move constant to right side of test in comparison
staging: rtl8723bs: remove empty if statement block
staging: rtl8723bs: simplify boolean return in IsFrameTypeCtrl()
staging: rtl8723bs: use read_poll_timeout_atomic in
_is_fw_read_cmd_down
staging: rtl8723bs: remove duplicate rate checks in
PHY_GetTxPowerIndexBase()

 .../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
 drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  5 +----
 drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 11 +++++------
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   | 18 +++++++-----------
 .../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
 drivers/staging/rtl8723bs/include/wifi.h       |  5 +----
 9 files changed, 29 insertions(+), 40 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/5 staging: rtl8723bs: move constant to right side of test in comparison

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---
 .../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
 drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
 drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
 .../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
 drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
 7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +9 -9
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 fwdl_stat:
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
index 0f28c904a714..0f378830462f 100644
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this
Signature · 1 line
2.34.1
Reviewed-by on v3 1/5
#2 lore raw

Re: [RFT PATCH v3 1/5] staging: rtl8723bs: move constant to right side of test in comparison

LGTM,

Quoted 167 lines · Prithvi Tambewagh

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---

.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -2
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 

fwdl_stat:

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +7 -7
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
index 0f28c904a714..0f378830462f 100644
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this
Reviewed-by on v3 1/5
#3 lore raw

Re: [RFT PATCH v3 1/5] staging: rtl8723bs: move constant to right side of test in comparison

In reply to Prithvi Tambewagh
Quoted 157 lines · Prithvi Tambewagh

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---

.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -2
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 

fwdl_stat:

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +7 -7
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 0f28c904a714..0f378830462f 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 402

Quoted 10 lines
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this

Sorry, I sent it from the wrong email.
Please use [email protected] instead of [email protected]. LGTM,

#4 lore raw

Re: [RFT PATCH v3 1/5] staging: rtl8723bs: move constant to right side of test in comparison

Quoted 167 lines · Luka Gejak
Quoted 166 lines · Prithvi Tambewagh

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---

.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -2
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 

fwdl_stat:

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +7 -7
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
index 0f28c904a714..0f378830462f 100644
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
Quoted 6 lines

drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 402

Quoted 1 line
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
 /* NOTE: This data is for statistical purposes; not all hardware provides this

Sorry, I sent it from the wrong email.
Please use [email protected] instead of [email protected]. LGTM,

This doesn't even apply to staging-next.

Thanks,

ET

#5 lore raw

Re: [RFT PATCH v3 1/5] staging: rtl8723bs: move constant to right side of test in comparison

In reply to Prithvi Tambewagh
Quoted 157 lines · Prithvi Tambewagh

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---

.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -2
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 

fwdl_stat:

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +7 -7
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 0f28c904a714..0f378830462f 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 402

Quoted 10 lines
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this

Didn't see ET pointed it out already, my bad.

#6 lore raw

Re: [RFT PATCH v3 1/5] staging: rtl8723bs: move constant to right side of test in comparison

In reply to Prithvi Tambewagh
Quoted 157 lines · Prithvi Tambewagh

Move constant from the left side to the right side of the test in a comparison, where ==, !=, <=, >=, <, > operators are used, fixing the checkpatch warning: Comparisons should place the constant on the right side of the test.

---

.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  2 +-
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c |  4 ++--
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
7 files changed, 18 insertions(+), 18 deletions(-)
drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +2 -2
index d32dbf94858f..58f6cf063498 100644
@@ -2211,7 +2211,7 @@ static void halbtc8723b2ant_RunCoexistMechanism(struct btc_coexist *pBtCoexist)
 	}
 
 	algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist);
-	if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) {
+	if (pCoexSta->bC2hBtInquiryPage && (algorithm != BT_8723B_2ANT_COEX_ALGO_PANHS)) {
 		halbtc8723b2ant_ActionBtInquiry(pBtCoexist);
 		return;
 	} else {
@@ -2490,7 +2490,7 @@ void EXhalbtc8723b2ant_BtInfoNotify(
 		return;
 	}
 
-	if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) {
+	if (rspSource != BT_INFO_SRC_8723B_2ANT_WIFI_FW) {
 		pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2] & 0xf; /* [3:0] */
 
 		pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3] * 2 + 10;
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +1 -1
index 9df3274c1048..9e7eebfc02a9 100644
@@ -313,7 +313,7 @@ static void GetDeltaSwingTable_8723B(
 	u16 rate = *(pDM_Odm->pForcedDataRate);
 	u8 channel = pHalData->CurrentChannel;
 
-	if (1 <= channel && channel <= 14) {
+	if (channel >= 1 && channel <= 14) {
 		if (IS_CCK_RATE(rate)) {
 			*TemperatureUP_A   = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P;
 			*TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N;
drivers/staging/rtl8723bs/hal/hal_com.c +1 -1
index 31b3e880ae6a..597ba3d283c1 100644
@@ -107,7 +107,7 @@ u8 hal_com_config_channel_plan(
 	pHalData->bDisableSWChannelPlan = false;
 	chnlPlan = def_channel_plan;
 
-	if (0xFF == hw_channel_plan)
+	if (hw_channel_plan == 0xFF)
 		AutoLoadFail = true;
 
 	if (!AutoLoadFail) {
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
index dc2da49e6738..9e523491a008 100644
@@ -462,11 +462,11 @@ u8 PHY_GetTxPowerIndexBase(
 
 	if (IS_CCK_RATE(Rate))
 		txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx];
-	else if (MGN_6M <= Rate)
+	else if (Rate >= MGN_6M)
 		txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx];
 
 	/*  OFDM-1T */
-	if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
+	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
 	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +2 -2
index 8d259820f103..02c3f4229e74 100644
@@ -405,11 +405,11 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
 			break;
 	}
 	_FWDownloadEnable(padapter, false);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 
 	rtStatus = _FWFreeToGo(padapter, 10, 200);
-	if (_SUCCESS != rtStatus)
+	if (rtStatus != _SUCCESS)
 		goto fwdl_stat;
 

fwdl_stat:

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +7 -7
@@ -1165,15 +1165,15 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter)
 
 static void hal_get_chnl_group_8723b(u8 channel, u8 *group)
 {
-	if (1  <= channel && channel <= 2)
+	if (channel >= 1 && channel <= 2)
 		*group = 0;
-	else if (3  <= channel && channel <= 5)
+	else if (channel >= 3 && channel <= 5)
 		*group = 1;
-	else if (6  <= channel && channel <= 8)
+	else if (channel >= 6 && channel <= 8)
 		*group = 2;
-	else if (9  <= channel && channel <= 11)
+	else if (channel >= 9 && channel <= 11)
 		*group = 3;
-	else if (12 <= channel && channel <= 14)
+	else if (channel >= 12 && channel <= 14)
 		*group = 4;
 }
 
@@ -1221,7 +1221,7 @@ static void Hal_ReadPowerValueFromPROM_8723B(
 
 	memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G));
 
-	if (0xFF == PROMContent[eeAddr+1])
+	if (PROMContent[eeAddr+1] == 0xFF)
 		AutoLoadFail = true;
 
 	if (AutoLoadFail) {
@@ -2035,7 +2035,7 @@ static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val)
 		val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT);
 
 		/*  Always enable port0 beacon function for PSTDMA */
-		if (REG_BCN_CTRL == bcn_ctrl_reg)
+		if (bcn_ctrl_reg == REG_BCN_CTRL)
 			val8 |= EN_BCN_FUNCTION;
 
 		rtw_write8(padapter, bcn_ctrl_reg, val8);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +1 -1
index a1f2cbf2cf55..9f6503ac2234 100644
@@ -413,7 +413,7 @@ int rtl8723bs_xmit_thread(void *context)
 		if (signal_pending(current)) {
 			flush_signals(current);
 		}
-	} while (_SUCCESS == ret);
+	} while (ret == _SUCCESS);
 
 	complete(&pxmitpriv->SdioXmitTerminate);
 
drivers/staging/rtl8723bs/include/ieee80211.h +0 -0
index 0f28c904a714..0f378830462f 100644

drivers/staging/rtl8723bs/include/ieee80211.h enum { · line 402

Quoted 10 lines
drivers/staging/rtl8723bs/include/ieee80211.h +2 -2
@@ -395,8 +395,8 @@ enum {
 };
 
 #define IS_HT_RATE(_rate)				(_rate >= MGN_MCS0 && _rate <= MGN_MCS31)
-#define IS_CCK_RATE(_rate)				(MGN_1M == _rate || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
-#define IS_OFDM_RATE(_rate)				(MGN_6M <= _rate && _rate <= MGN_54M  && _rate != MGN_11M)
+#define IS_CCK_RATE(_rate)				(_rate == MGN_1M || _rate == MGN_2M || _rate == MGN_5_5M || _rate == MGN_11M)
+#define IS_OFDM_RATE(_rate)				(_rate >= MGN_6M && _rate <= MGN_54M  && _rate != MGN_11M)
 
 
 /* NOTE: This data is for statistical purposes; not all hardware provides this

Doesn't apply to staging-next either.
Best regards,
Luka Gejak

#7 lore raw

PATCH v3 2/5 staging: rtl8723bs: remove empty if statement block

In reply to Prithvi Tambewagh

Remove empty if statement block for cleaning up code.

---
 drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +0 -3
index 9e7eebfc02a9..61b35173aa4f 100644
@@ -1425,9 +1425,6 @@ static void phy_IQCalibrate_8723B(
 		}
 	}
 
-	if (0x00 == PathAOK) {
-	}
-
 /* path B IQK */
 	if (is2T) {
 
Signature · 1 line
2.34.1
Reviewed-by on v3 2/5
#8 lore raw

Re: [RFT PATCH v3 2/5] staging: rtl8723bs: remove empty if statement block

Quoted 12 lines · Prithvi Tambewagh

Remove empty if statement block for cleaning up code.

---
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 3 ---

1 file changed, 3 deletions(-)
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +0 -0
index 9e7eebfc02a9..61b35173aa4f 100644

drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c static void phy_IQCalibrate_8723B( · line 1430

Quoted 9 lines
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +0 -3
@@ -1425,9 +1425,6 @@ static void phy_IQCalibrate_8723B(
 		}
 	}
 
-	if (0x00 == PathAOK) {
-	}
-
 /* path B IQK */
 	if (is2T) {
 

LGTM,

#9 lore raw

PATCH v3 3/5 staging: rtl8723bs: simplify boolean return in IsFrameTypeCtrl()

In reply to Prithvi Tambewagh

Replace the simple if-else statement which checked value of GetFrameType(pframe), if equal to WIFI_CTRL_TYPE, function IsFrameTypeCtrl() returned true else false, with a single return statement returning true only if GetFrameType(pframe) == WIFI_CTRL_TYPE otherwise returns false.

---
 drivers/staging/rtl8723bs/include/wifi.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8723bs/include/wifi.h +1 -4
index 230b2c4ffd3b..2876f15f13d1 100644
@@ -275,10 +275,7 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 
 static inline int IsFrameTypeCtrl(unsigned char *pframe)
 {
-	if (WIFI_CTRL_TYPE == GetFrameType(pframe))
-		return true;
-	else
-		return false;
+	return GetFrameType(pframe) == WIFI_CTRL_TYPE;
 }
 /*-----------------------------------------------------------------------------
 			Below is for the security related definition
Signature · 1 line
2.34.1
Reviewed-by on v3 3/5
#10 lore raw

Re: [RFT PATCH v3 3/5] staging: rtl8723bs: simplify boolean return in IsFrameTypeCtrl()

Quoted 17 lines · Prithvi Tambewagh

Replace the simple if-else statement which checked value of GetFrameType(pframe), if equal to WIFI_CTRL_TYPE, function IsFrameTypeCtrl() returned true else false, with a single return statement returning true only if GetFrameType(pframe) == WIFI_CTRL_TYPE otherwise returns false.

---
drivers/staging/rtl8723bs/include/wifi.h | 5 +----

1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8723bs/include/wifi.h +0 -0
index 230b2c4ffd3b..2876f15f13d1 100644
@@ -275,10 +275,7 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 

drivers/staging/rtl8723bs/include/wifi.h static inline unsigned char *get_hdr_bssid(unsigned char *pframe) · line 281

Quoted 10 lines
drivers/staging/rtl8723bs/include/wifi.h +1 -4
 static inline int IsFrameTypeCtrl(unsigned char *pframe)
 {
-	if (WIFI_CTRL_TYPE == GetFrameType(pframe))
-		return true;
-	else
-		return false;
+	return GetFrameType(pframe) == WIFI_CTRL_TYPE;
 }
 /*-----------------------------------------------------------------------------
 			Below is for the security related definition

LGTM,

#11 lore raw

PATCH v3 4/5 staging: rtl8723bs: use read_poll_timeout_atomic in _is_fw_read_cmd_down

In reply to Prithvi Tambewagh

Replace the existing rtw_read8() and do-while loop mechanism with read_poll_timeout_atomic() from <linux/iopoll.h>, in _is_fw_read_cmd_down() which is a standard Linux macro, ensuring polling REG_HMETFR efficiently.

---
 drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +7 -11
index af6cdda8238d..17e135cd3e0e 100644
@@ -8,6 +8,7 @@
 #include <drv_types.h>
 #include <rtl8723b_hal.h>
 #include <linux/etherdevice.h>
+#include <linux/iopoll.h>
 #include "hal_com_h2c.h"
 
 #define MAX_H2C_BOX_NUMS	4
@@ -18,20 +19,15 @@
 
 static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num)
 {
-	u8 read_down = false;
-	int retry_cnts = 100;
-
 	u8 valid;
+	int ret;
 
-	do {
-		valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num);
-		if (0 == valid) {
-			read_down = true;
-		}
-	} while ((!read_down) && (retry_cnts--));
-
-	return read_down;
+	ret = read_poll_timeout_atomic(rtw_read8,
+				       valid, !(valid & BIT(msgbox_num)),
+				       0, 500, false,
+				       padapter, REG_HMETFR);
 
+	return !ret;
 }
 
 
Signature · 1 line
2.34.1
Reviewed-by on v3 4/5
#12 lore raw

Re: [RFT PATCH v3 4/5] staging: rtl8723bs: use read_poll_timeout_atomic in _is_fw_read_cmd_down

Quoted 38 lines · Prithvi Tambewagh

Replace the existing rtw_read8() and do-while loop mechanism with read_poll_timeout_atomic() from <linux/iopoll.h>, in _is_fw_read_cmd_down() which is a standard Linux macro, ensuring polling REG_HMETFR efficiently.

---
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 18 +++++++-----------

1 file changed, 7 insertions(+), 11 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +2 -10
index af6cdda8238d..17e135cd3e0e 100644
@@ -8,6 +8,7 @@
 #include <drv_types.h>
 #include <rtl8723b_hal.h>
 #include <linux/etherdevice.h>
+#include <linux/iopoll.h>
 #include "hal_com_h2c.h"
 
 #define MAX_H2C_BOX_NUMS	4
@@ -18,20 +19,15 @@
 
 static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num)
 {
-	u8 read_down = false;
-	int retry_cnts = 100;
-
 	u8 valid;
+	int ret;
 
-	do {
-		valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num);
-		if (0 == valid) {
-			read_down = true;
-		}
-	} while ((!read_down) && (retry_cnts--));
-

drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c line 33

Quoted 10 lines
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +5 -1
-	return read_down;
+	ret = read_poll_timeout_atomic(rtw_read8,
+				       valid, !(valid & BIT(msgbox_num)),
+				       0, 500, false,
+				       padapter, REG_HMETFR);
 
+	return !ret;
 }
 
 

LGTM,

#13 lore raw

PATCH v3 5/5 staging: rtl8723bs: remove duplicate rate checks in PHY_GetTxPowerIndexBase()

In reply to Prithvi Tambewagh

The code previously checked (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) condition twice - once for the (BandWidth == CHANNEL_WIDTH_20) check and once for the (BandWidth == CHANNEL_WIDTH_40) check. Fix if statement formatting to move that if check as an outer if check to improve code formatting.

---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -4
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
 	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+	if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+		if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
 			txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-	} else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+		else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
 			txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v3 5/5
#14 lore raw

Re: [RFT PATCH v3 5/5] staging: rtl8723bs: remove duplicate rate checks in PHY_GetTxPowerIndexBase()

Quoted 20 lines · Prithvi Tambewagh

The code previously checked (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) condition twice - once for the (BandWidth == CHANNEL_WIDTH_20) check and once for the (BandWidth == CHANNEL_WIDTH_40) check. Fix if statement formatting to move that if check as an outer if check to improve code formatting.

---
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 7 +++----

1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +0 -1
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
 	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */

drivers/staging/rtl8723bs/hal/hal_com_phycfg.c u8 PHY_GetTxPowerIndexBase( · line 478

Quoted 10 lines
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -3
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+	if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+		if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
 			txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-	} else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+		else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
 			txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
 	}
 

LGTM,

#15 lore raw

Re: [RFT PATCH v3 5/5] staging: rtl8723bs: remove duplicate rate checks in PHY_GetTxPowerIndexBase()

Quoted 33 lines · Luka Gejak
Quoted 20 lines · Prithvi Tambewagh

The code previously checked (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) condition twice - once for the (BandWidth == CHANNEL_WIDTH_20) check and once for the (BandWidth == CHANNEL_WIDTH_40) check. Fix if statement formatting to move that if check as an outer if check to improve code formatting.

---
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 7 +++----

1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +0 -1
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
 	if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
 		txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-	if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */

drivers/staging/rtl8723bs/hal/hal_com_phycfg.c u8 PHY_GetTxPowerIndexBase( · line 478

Quoted 10 lines
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -3
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+	if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+		if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
 			txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-	} else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-		if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+		else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
 			txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
 	}
 

LGTM,

Quoted 1 line

Doesn't apply to staging-next too.

Thanks,

ET

#16 lore raw
In reply to Prithvi Tambewagh
Quoted 268 lines · Prithvi Tambewagh

This patch series focuses on code cleanup in drivers/staging/rtl8723bs, majorly focusing on fixing checkpatch warnings of constant being on right side of test in comparisons, deletion of empty if block ,use of read_poll_timeout_atomic(), and other code simplifications.

v2 link: https://lore.kernel.org/linux-staging/20260403094647.fmgop6xh2cjpit3s@inspiron/T/#m3d08fd012119772e>
v1 link: https://lore.kernel.org/linux-staging/20260323145214.ubhshy2gwp52j5zh@inspiron/T/#mc3b693b37c49fbdd>

Note:
1. I found that for this change in v2:

(quoted diff) +2 -4
-       if (
-               (false == pHalData->bDisableSWChannelPlan) &&
-               rtw_is_channel_plan_valid(sw_channel_plan)
-       )
+       if (!pHalData->bDisableSWChannelPlan &&
+           rtw_is_channel_plan_valid(sw_channel_plan))

for this code, checkpatch gave the check:

CHECK: Using comparison to false is error prone #126: FILE: drivers/staging/rtl8723bs/hal/hal_com.c:126:
+ (false == pHalData->bDisableSWChannelPlan) &&

which is a different logical change than the ones covered in this patch series. Hence, to keep the patch series to a reasonable length and since this is RFT path series, I did not consider this change right now.

2. This change in v2:

       if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                       txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
       } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                       txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
       }

can be reformatted as:

drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -4
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
       if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
               txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-       if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+       if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+               if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
                       txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-       } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
                       txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];

for which it is sent as a separate patch - patch 5 in this series.

3. I found, in drivers/staging/rtl8723bs/hal/odm.h:

struct odm_rate_adaptive {
u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */
u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */
bool bUseLdpc;
bool bLowerRtsRate;
u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */
u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */
u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_>

};

and based on the explanation of parameters HighRSSIThresh & LowRSSIThresh I thought this change:

drivers/staging/rtl8723bs/hal/odm.c +2 -2
index 639b6da2302b..ca4495f101fd 100644
@@ -343,9 +343,9 @@ bool ODM_RAStateCheck(
       }
 
       /*  Decide RATRState by RSSI. */
-       if (RSSI > HighRSSIThreshForRA)
+       if (HighRSSIThreshForRA < RSSI)
               RATRState = DM_RATR_STA_HIGH;
-       else if (RSSI > LowRSSIThreshForRA)
+       else if (LowRSSIThreshForRA < RSSI) 
               RATRState = DM_RATR_STA_MIDDLE;
      else
               RATRState = DM_RATR_STA_LOW;

doesn't seem to be right, thats why I dropped this change as well.

4. This patch series is compile tested using the following commands, which include setting the necessary configurations:
1. make defconfig
2. scripts/config --enable CONFIG_STAGING
3. scripts/config --module CONFIG_MMC
4. scripts/config --module CONFIG_RTL8723BS
5. make olddefconfig
6. make -j$(nproc)
7. git rebase -i --exec "make -j$(nproc) M=drivers/staging/rtl8723bs" HEAD~5

The final rebase --exec gave a successful output:

Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

 CC [M]  core/rtw_ap.o
 CC [M]  core/rtw_btcoex.o
 CC [M]  core/rtw_cmd.o
 CC [M]  core/rtw_efuse.o
 CC [M]  core/rtw_io.o
 CC [M]  core/rtw_ioctl_set.o
 CC [M]  core/rtw_ieee80211.o
 CC [M]  core/rtw_mlme.o
 CC [M]  core/rtw_mlme_ext.o
 CC [M]  core/rtw_pwrctrl.o
 CC [M]  core/rtw_recv.o
 CC [M]  core/rtw_security.o
 CC [M]  core/rtw_sta_mgt.o
 CC [M]  core/rtw_wlan_util.o
 CC [M]  core/rtw_xmit.o
 CC [M]  hal/hal_intf.o
 CC [M]  hal/hal_com.o
 CC [M]  hal/hal_com_phycfg.o
 CC [M]  hal/hal_btcoex.o
 CC [M]  hal/hal_sdio.o
 CC [M]  hal/hal_pwr_seq.o
 CC [M]  hal/HalPhyRf.o
 CC [M]  hal/HalPwrSeqCmd.o
 CC [M]  hal/odm_CfoTracking.o
 CC [M]  hal/odm.o
 CC [M]  hal/odm_DIG.o
 CC [M]  hal/odm_DynamicBBPowerSaving.o
 CC [M]  hal/odm_DynamicTxPower.o
 CC [M]  hal/odm_EdcaTurboCheck.o
 CC [M]  hal/odm_HWConfig.o
 CC [M]  hal/odm_RegConfig8723B.o
 CC [M]  hal/rtl8723b_cmd.o
 CC [M]  hal/rtl8723b_dm.o
 CC [M]  hal/rtl8723b_hal_init.o
 CC [M]  hal/rtl8723b_phycfg.o
 CC [M]  hal/rtl8723b_rf6052.o
 CC [M]  hal/rtl8723b_rxdesc.o
 CC [M]  hal/rtl8723bs_recv.o
 CC [M]  hal/rtl8723bs_xmit.o
 CC [M]  hal/sdio_halinit.o
 CC [M]  hal/sdio_ops.o
 CC [M]  hal/HalBtc8723b1Ant.o
 CC [M]  hal/HalBtc8723b2Ant.o
 CC [M]  hal/HalHWImg8723B_BB.o
 CC [M]  hal/HalHWImg8723B_MAC.o
 CC [M]  hal/HalHWImg8723B_RF.o
 CC [M]  hal/HalPhyRf_8723B.o
 CC [M]  os_dep/ioctl_cfg80211.o
 CC [M]  os_dep/osdep_service.o
 CC [M]  os_dep/os_intfs.o
 CC [M]  os_dep/sdio_intf.o
 CC [M]  os_dep/sdio_ops_linux.o
 CC [M]  os_dep/wifi_regd.o
 CC [M]  os_dep/xmit_linux.o
 LD [M]  r8723bs.o
 MODPOST Module.symvers
 CC [M]  r8723bs.mod.o
 CC [M]  .module-common.o
 LD [M]  r8723bs.ko

make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/HalPhyRf_8723B.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

 CC [M]  core/rtw_ap.o
 CC [M]  core/rtw_btcoex.o
 CC [M]  core/rtw_cmd.o
 CC [M]  core/rtw_efuse.o
 CC [M]  core/rtw_io.o
 CC [M]  core/rtw_ioctl_set.o
 CC [M]  core/rtw_ieee80211.o
 CC [M]  core/rtw_mlme.o
 CC [M]  core/rtw_mlme_ext.o
 CC [M]  core/rtw_pwrctrl.o
 CC [M]  core/rtw_recv.o
 CC [M]  core/rtw_security.o
 CC [M]  core/rtw_sta_mgt.o
 CC [M]  core/rtw_wlan_util.o
 CC [M]  core/rtw_xmit.o
 CC [M]  hal/hal_intf.o
 CC [M]  hal/hal_com.o
 CC [M]  hal/hal_com_phycfg.o
 CC [M]  hal/hal_btcoex.o
 CC [M]  hal/hal_sdio.o
 CC [M]  hal/hal_pwr_seq.o
 CC [M]  hal/HalPhyRf.o
 CC [M]  hal/HalPwrSeqCmd.o
 CC [M]  hal/odm.o
 CC [M]  hal/odm_CfoTracking.o
 CC [M]  hal/odm_DIG.o
 CC [M]  hal/odm_DynamicBBPowerSaving.o
 CC [M]  hal/odm_DynamicTxPower.o
 CC [M]  hal/odm_EdcaTurboCheck.o
 CC [M]  hal/odm_HWConfig.o
 CC [M]  hal/odm_RegConfig8723B.o
 CC [M]  hal/rtl8723b_cmd.o
 CC [M]  hal/rtl8723b_dm.o
 CC [M]  hal/rtl8723b_hal_init.o
 CC [M]  hal/rtl8723b_phycfg.o
 CC [M]  hal/rtl8723b_rf6052.o
 CC [M]  hal/rtl8723b_rxdesc.o
 CC [M]  hal/rtl8723bs_recv.o
 CC [M]  hal/rtl8723bs_xmit.o
 CC [M]  hal/sdio_halinit.o
 CC [M]  hal/sdio_ops.o
 CC [M]  hal/HalBtc8723b1Ant.o
 CC [M]  hal/HalBtc8723b2Ant.o
 CC [M]  hal/HalHWImg8723B_BB.o
 CC [M]  hal/HalHWImg8723B_MAC.o
 CC [M]  hal/HalHWImg8723B_RF.o
 CC [M]  hal/HalPhyRf_8723B.o
 CC [M]  os_dep/ioctl_cfg80211.o
 CC [M]  os_dep/osdep_service.o
 CC [M]  os_dep/os_intfs.o
 CC [M]  os_dep/sdio_intf.o
 CC [M]  os_dep/sdio_ops_linux.o
 CC [M]  os_dep/wifi_regd.o
 CC [M]  os_dep/xmit_linux.o
 LD [M]  r8723bs.o

MODPOST Module.symvers
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/rtl8723b_cmd.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/hal_com_phycfg.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs' Successfully rebased and updated refs/heads/staging-realtek-patch-series.

However, since I currently don't have rtl8723bs hardware I am unfortunately unable to do runtime testing for this patch series.

Prithvi Tambewagh (5):
staging: rtl8723bs: move constant to right side of test in comparison
staging: rtl8723bs: remove empty if statement block
staging: rtl8723bs: simplify boolean return in IsFrameTypeCtrl()
staging: rtl8723bs: use read_poll_timeout_atomic in
_is_fw_read_cmd_down
staging: rtl8723bs: remove duplicate rate checks in
PHY_GetTxPowerIndexBase()

Quoted 11 lines
.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  5 +----
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 11 +++++------
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   | 18 +++++++-----------
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
drivers/staging/rtl8723bs/include/wifi.h       |  5 +----
9 files changed, 29 insertions(+), 40 deletions(-)

Hi Prithvi,
You do not need to provide compilation output in cover letter, also since these are only style changes, I believe testing is not necessary. Furthermore, it would be better to list changes in v2/v3 rather than pasting code snippets here.
Best regards,
Luka Gejak

author
#17 lore raw
Quoted 281 lines · Luka Gejak
Quoted 268 lines · Prithvi Tambewagh

This patch series focuses on code cleanup in drivers/staging/rtl8723bs, majorly focusing on fixing checkpatch warnings of constant being on right side of test in comparisons, deletion of empty if block ,use of read_poll_timeout_atomic(), and other code simplifications.

v2 link: https://lore.kernel.org/linux-staging/20260403094647.fmgop6xh2cjpit3s@inspiron/T/#m3d08fd012119772e>
v1 link: https://lore.kernel.org/linux-staging/20260323145214.ubhshy2gwp52j5zh@inspiron/T/#mc3b693b37c49fbdd>

Note:
1. I found that for this change in v2:

(quoted diff) +2 -4
-       if (
-               (false == pHalData->bDisableSWChannelPlan) &&
-               rtw_is_channel_plan_valid(sw_channel_plan)
-       )
+       if (!pHalData->bDisableSWChannelPlan &&
+           rtw_is_channel_plan_valid(sw_channel_plan))

for this code, checkpatch gave the check:

CHECK: Using comparison to false is error prone #126: FILE: drivers/staging/rtl8723bs/hal/hal_com.c:126:
+ (false == pHalData->bDisableSWChannelPlan) &&

which is a different logical change than the ones covered in this patch series. Hence, to keep the patch series to a reasonable length and since this is RFT path series, I did not consider this change right now.

2. This change in v2:

       if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +2 -2
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                       txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
       } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7)
                       txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];
       }

can be reformatted as:

drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +3 -4
index 9e523491a008..efd1c76f2953 100644
@@ -469,11 +469,10 @@ u8 PHY_GetTxPowerIndexBase(
       if ((Rate >= MGN_6M && Rate <= MGN_54M) && !IS_CCK_RATE(Rate))
               txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S];
 
-       if (BandWidth == CHANNEL_WIDTH_20) { /*  BW20-1S, BW20-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+       if (Rate >= MGN_MCS0 && Rate <= MGN_MCS7) {
+               if (BandWidth == CHANNEL_WIDTH_20) /*  BW20-1S, BW20-2S */
                       txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S];
-       } else if (BandWidth == CHANNEL_WIDTH_40) { /*  BW40-1S, BW40-2S */
-               if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7)
+               else if (BandWidth == CHANNEL_WIDTH_40) /*  BW40-1S, BW40-2S */
                       txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S];

for which it is sent as a separate patch - patch 5 in this series.

3. I found, in drivers/staging/rtl8723bs/hal/odm.h:

struct odm_rate_adaptive {
u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */
u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */
bool bUseLdpc;
bool bLowerRtsRate;
u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */
u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */
u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_>

};

and based on the explanation of parameters HighRSSIThresh & LowRSSIThresh I thought this change:

drivers/staging/rtl8723bs/hal/odm.c +2 -2
index 639b6da2302b..ca4495f101fd 100644
@@ -343,9 +343,9 @@ bool ODM_RAStateCheck(
       }
 
       /*  Decide RATRState by RSSI. */
-       if (RSSI > HighRSSIThreshForRA)
+       if (HighRSSIThreshForRA < RSSI)
               RATRState = DM_RATR_STA_HIGH;
-       else if (RSSI > LowRSSIThreshForRA)
+       else if (LowRSSIThreshForRA < RSSI) 
               RATRState = DM_RATR_STA_MIDDLE;
      else
               RATRState = DM_RATR_STA_LOW;

doesn't seem to be right, thats why I dropped this change as well.

4. This patch series is compile tested using the following commands, which include setting the necessary configurations:
1. make defconfig
2. scripts/config --enable CONFIG_STAGING
3. scripts/config --module CONFIG_MMC
4. scripts/config --module CONFIG_RTL8723BS
5. make olddefconfig
6. make -j$(nproc)
7. git rebase -i --exec "make -j$(nproc) M=drivers/staging/rtl8723bs" HEAD~5

The final rebase --exec gave a successful output:

Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

 CC [M]  core/rtw_ap.o
 CC [M]  core/rtw_btcoex.o
 CC [M]  core/rtw_cmd.o
 CC [M]  core/rtw_efuse.o
 CC [M]  core/rtw_io.o
 CC [M]  core/rtw_ioctl_set.o
 CC [M]  core/rtw_ieee80211.o
 CC [M]  core/rtw_mlme.o
 CC [M]  core/rtw_mlme_ext.o
 CC [M]  core/rtw_pwrctrl.o
 CC [M]  core/rtw_recv.o
 CC [M]  core/rtw_security.o
 CC [M]  core/rtw_sta_mgt.o
 CC [M]  core/rtw_wlan_util.o
 CC [M]  core/rtw_xmit.o
 CC [M]  hal/hal_intf.o
 CC [M]  hal/hal_com.o
 CC [M]  hal/hal_com_phycfg.o
 CC [M]  hal/hal_btcoex.o
 CC [M]  hal/hal_sdio.o
 CC [M]  hal/hal_pwr_seq.o
 CC [M]  hal/HalPhyRf.o
 CC [M]  hal/HalPwrSeqCmd.o
 CC [M]  hal/odm_CfoTracking.o
 CC [M]  hal/odm.o
 CC [M]  hal/odm_DIG.o
 CC [M]  hal/odm_DynamicBBPowerSaving.o
 CC [M]  hal/odm_DynamicTxPower.o
 CC [M]  hal/odm_EdcaTurboCheck.o
 CC [M]  hal/odm_HWConfig.o
 CC [M]  hal/odm_RegConfig8723B.o
 CC [M]  hal/rtl8723b_cmd.o
 CC [M]  hal/rtl8723b_dm.o
 CC [M]  hal/rtl8723b_hal_init.o
 CC [M]  hal/rtl8723b_phycfg.o
 CC [M]  hal/rtl8723b_rf6052.o
 CC [M]  hal/rtl8723b_rxdesc.o
 CC [M]  hal/rtl8723bs_recv.o
 CC [M]  hal/rtl8723bs_xmit.o
 CC [M]  hal/sdio_halinit.o
 CC [M]  hal/sdio_ops.o
 CC [M]  hal/HalBtc8723b1Ant.o
 CC [M]  hal/HalBtc8723b2Ant.o
 CC [M]  hal/HalHWImg8723B_BB.o
 CC [M]  hal/HalHWImg8723B_MAC.o
 CC [M]  hal/HalHWImg8723B_RF.o
 CC [M]  hal/HalPhyRf_8723B.o
 CC [M]  os_dep/ioctl_cfg80211.o
 CC [M]  os_dep/osdep_service.o
 CC [M]  os_dep/os_intfs.o
 CC [M]  os_dep/sdio_intf.o
 CC [M]  os_dep/sdio_ops_linux.o
 CC [M]  os_dep/wifi_regd.o
 CC [M]  os_dep/xmit_linux.o
 LD [M]  r8723bs.o
 MODPOST Module.symvers
 CC [M]  r8723bs.mod.o
 CC [M]  .module-common.o
 LD [M]  r8723bs.ko

make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/HalPhyRf_8723B.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'

 CC [M]  core/rtw_ap.o
 CC [M]  core/rtw_btcoex.o
 CC [M]  core/rtw_cmd.o
 CC [M]  core/rtw_efuse.o
 CC [M]  core/rtw_io.o
 CC [M]  core/rtw_ioctl_set.o
 CC [M]  core/rtw_ieee80211.o
 CC [M]  core/rtw_mlme.o
 CC [M]  core/rtw_mlme_ext.o
 CC [M]  core/rtw_pwrctrl.o
 CC [M]  core/rtw_recv.o
 CC [M]  core/rtw_security.o
 CC [M]  core/rtw_sta_mgt.o
 CC [M]  core/rtw_wlan_util.o
 CC [M]  core/rtw_xmit.o
 CC [M]  hal/hal_intf.o
 CC [M]  hal/hal_com.o
 CC [M]  hal/hal_com_phycfg.o
 CC [M]  hal/hal_btcoex.o
 CC [M]  hal/hal_sdio.o
 CC [M]  hal/hal_pwr_seq.o
 CC [M]  hal/HalPhyRf.o
 CC [M]  hal/HalPwrSeqCmd.o
 CC [M]  hal/odm.o
 CC [M]  hal/odm_CfoTracking.o
 CC [M]  hal/odm_DIG.o
 CC [M]  hal/odm_DynamicBBPowerSaving.o
 CC [M]  hal/odm_DynamicTxPower.o
 CC [M]  hal/odm_EdcaTurboCheck.o
 CC [M]  hal/odm_HWConfig.o
 CC [M]  hal/odm_RegConfig8723B.o
 CC [M]  hal/rtl8723b_cmd.o
 CC [M]  hal/rtl8723b_dm.o
 CC [M]  hal/rtl8723b_hal_init.o
 CC [M]  hal/rtl8723b_phycfg.o
 CC [M]  hal/rtl8723b_rf6052.o
 CC [M]  hal/rtl8723b_rxdesc.o
 CC [M]  hal/rtl8723bs_recv.o
 CC [M]  hal/rtl8723bs_xmit.o
 CC [M]  hal/sdio_halinit.o
 CC [M]  hal/sdio_ops.o
 CC [M]  hal/HalBtc8723b1Ant.o
 CC [M]  hal/HalBtc8723b2Ant.o
 CC [M]  hal/HalHWImg8723B_BB.o
 CC [M]  hal/HalHWImg8723B_MAC.o
 CC [M]  hal/HalHWImg8723B_RF.o
 CC [M]  hal/HalPhyRf_8723B.o
 CC [M]  os_dep/ioctl_cfg80211.o
 CC [M]  os_dep/osdep_service.o
 CC [M]  os_dep/os_intfs.o
 CC [M]  os_dep/sdio_intf.o
 CC [M]  os_dep/sdio_ops_linux.o
 CC [M]  os_dep/wifi_regd.o
 CC [M]  os_dep/xmit_linux.o
 LD [M]  r8723bs.o

MODPOST Module.symvers
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/rtl8723b_cmd.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
Executing: make -j12 M=drivers/staging/rtl8723bs
make[1]: Entering directory '/home/prithvi/linux/drivers/staging/rtl8723bs'
CC [M] hal/hal_com_phycfg.o
LD [M] r8723bs.o
MODPOST Module.symvers
CC [M] r8723bs.mod.o
LD [M] r8723bs.ko
make[1]: Leaving directory '/home/prithvi/linux/drivers/staging/rtl8723bs' Successfully rebased and updated refs/heads/staging-realtek-patch-series.

However, since I currently don't have rtl8723bs hardware I am unfortunately unable to do runtime testing for this patch series.

Prithvi Tambewagh (5):
staging: rtl8723bs: move constant to right side of test in comparison
staging: rtl8723bs: remove empty if statement block
staging: rtl8723bs: simplify boolean return in IsFrameTypeCtrl()
staging: rtl8723bs: use read_poll_timeout_atomic in
_is_fw_read_cmd_down
staging: rtl8723bs: remove duplicate rate checks in
PHY_GetTxPowerIndexBase()

Quoted 11 lines
.../staging/rtl8723bs/hal/HalBtc8723b2Ant.c    |  4 ++--
drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c |  5 +----
drivers/staging/rtl8723bs/hal/hal_com.c        |  2 +-
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 11 +++++------
drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c   | 18 +++++++-----------
.../staging/rtl8723bs/hal/rtl8723b_hal_init.c  | 18 +++++++++---------
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c |  2 +-
drivers/staging/rtl8723bs/include/ieee80211.h  |  4 ++--
drivers/staging/rtl8723bs/include/wifi.h       |  5 +----
9 files changed, 29 insertions(+), 40 deletions(-)
Quoted 7 lines

Hi Prithvi,
You do not need to provide compilation output in cover letter, also since these are only style changes, I believe testing is not necessary. Furthermore, it would be better to list changes in v2/v3 rather than pasting code snippets here.
Best regards,
Luka Gejak

Hi Luka,

Thanks for the feedback - I will incorporate it in v4 patch series; also since you said these are only style changes and testing isn't necessary I will remove the RFT tag from v4 patch series.

Best Reagrds,
Prithvi

author
#18 lore raw
In reply to Prithvi Tambewagh

Hi Ethan and Luka,

Thanks for taking time to apply this patch series to staging-next; I apologize for it not being possible to apply this patch series. I just realised that I mistakenly was working on mainline kernel's staging directory rather than staging tree - probably thats the issue here...my bad

I will send a v4 patch series to rectify this issue.

Thanks,
Prithvi

#19 lore raw
Quoted 8 lines · Prithvi

Hi Ethan and Luka,

Thanks for taking time to apply this patch series to staging-next; I apologize for it not being possible to apply this patch series. I just realised that I mistakenly was working on mainline kernel's staging directory rather than staging tree - probably thats the issue here...my bad

Quoted 4 lines

I will send a v4 patch series to rectify this issue.

Thanks,
Prithvi

Hi Prithvi,
That's kind of what we were implying by saying, "not applying to staging-next", but don't worry it's all part of the learning process. Please rebase on top of staging-next and integrate all mentioned changes in v4.
Best regards,
Luka Gejak

author
#20 lore raw
Quoted 14 lines · Luka Gejak
Quoted 8 lines · Prithvi

Hi Ethan and Luka,

Thanks for taking time to apply this patch series to staging-next; I apologize for it not being possible to apply this patch series. I just realised that I mistakenly was working on mainline kernel's staging directory rather than staging tree - probably thats the issue here...my bad

Quoted 4 lines

I will send a v4 patch series to rectify this issue.

Thanks,
Prithvi

Quoted 7 lines

Hi Prithvi,
That's kind of what we were implying by saying, "not applying to staging-next", but don't worry it's all part of the learning process. Please rebase on top of staging-next and integrate all mentioned changes in v4.
Best regards,
Luka Gejak

Thanks Luka :)

I'll send v4 patch series shortly.

Best Reagrds,
Prithvi