All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'.
@ 2018-06-17  5:30 Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 02/11] staging: rtl8723bs: Rename PHY_GetTxPowerLimit() Quytelda Kahja
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Wrap lines longer than 80 characters where possible, delete double
newlines, and fix alignment per the kernel coding style guidelines.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 .../staging/rtl8723bs/hal/hal_com_phycfg.c    | 110 ++++++++++--------
 1 file changed, 59 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 3922d0308a81..5f727a7c16fd 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1612,46 +1612,45 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
 	return channelIndex;
 }
 
-s8 PHY_GetTxPowerLimit(
-	struct adapter *Adapter,
-	u32 RegPwrTblSel,
-	enum BAND_TYPE Band,
-	enum CHANNEL_WIDTH Bandwidth,
-	u8 RfPath,
-	u8 DataRate,
-	u8 Channel
-)
+s8 PHY_GetTxPowerLimit(struct adapter *Adapter, u32 RegPwrTblSel,
+		       enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
+		       u8 RfPath, u8 DataRate, u8 Channel)
 {
-	struct hal_com_data	*pHalData = GET_HAL_DATA(Adapter);
-	s16	band = -1, regulation = -1, bandwidth = -1, rateSection = -1, channel = -1;
+	s16 band        = -1;
+	s16 regulation  = -1;
+	s16 bandwidth   = -1;
+	s16 rateSection = -1;
+	s16 channel     = -1;
 	s8 powerLimit = MAX_POWER_INDEX;
+	struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
 
-	if ((Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory != 1) ||
-		   Adapter->registrypriv.RegEnableTxPowerLimit == 0)
+	if (((Adapter->registrypriv.RegEnableTxPowerLimit == 2) &&
+	     (pHalData->EEPROMRegulatory != 1)) ||
+	    (Adapter->registrypriv.RegEnableTxPowerLimit == 0))
 		return MAX_POWER_INDEX;
 
 	switch (Adapter->registrypriv.RegPwrTblSel) {
 	case 1:
-			regulation = TXPWR_LMT_ETSI;
-			break;
+		regulation = TXPWR_LMT_ETSI;
+		break;
 	case 2:
-			regulation = TXPWR_LMT_MKK;
-			break;
+		regulation = TXPWR_LMT_MKK;
+		break;
 	case 3:
-			regulation = TXPWR_LMT_FCC;
-			break;
-
+		regulation = TXPWR_LMT_FCC;
+		break;
 	case 4:
-			regulation = TXPWR_LMT_WW;
-			break;
-
+		regulation = TXPWR_LMT_WW;
+		break;
 	default:
-			regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G : pHalData->Regulation5G;
-			break;
+		regulation = (Band == BAND_ON_2_4G) ?
+			pHalData->Regulation2_4G :
+			pHalData->Regulation5G;
+		break;
 	}
 
-	/* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation); */
-
+	/* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */
+	/*         Adapter->registrypriv.RegPwrTblSel, regulation); */
 
 	if (Band == BAND_ON_2_4G)
 		band = 0;
@@ -1730,8 +1729,8 @@ s8 PHY_GetTxPowerLimit(
 		break;
 	}
 
-	if (Band == BAND_ON_5G  && rateSection == 0)
-			DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
+	if (Band == BAND_ON_5G && rateSection == 0)
+                DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
 
 	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  OFDM only exists in BW 20M */
@@ -1745,22 +1744,26 @@ s8 PHY_GetTxPowerLimit(
 
 	/*  workaround for wrong indxe combination to obtain tx power limit, */
 	/*  HT on 80M will reference to HT on 40M */
-	if ((rateSection == 2 || rateSection == 3) && Band == BAND_ON_5G && bandwidth == 2) {
+	if ((rateSection == 2 || rateSection == 3) &&
+	    Band == BAND_ON_5G && bandwidth == 2) {
 		bandwidth = 1;
 	}
 
 	if (Band == BAND_ON_2_4G)
-		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, Channel);
+		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G,
+							    Channel);
 	else if (Band == BAND_ON_5G)
-		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, Channel);
+		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G,
+							    Channel);
 	else if (Band == BAND_ON_BOTH) {
 		/*  BAND_ON_BOTH don't care temporarily */
 	}
 
 	if (band == -1 || regulation == -1 || bandwidth == -1 ||
-	     rateSection == -1 || channel == -1) {
+	    rateSection == -1 || channel == -1) {
 		/* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */
-		/*	  band, regulation, bandwidth, RfPath, rateSection, channelGroup); */
+		/*         band, regulation, bandwidth, RfPath, */
+		/*         rateSection, channelGroup); */
 
 		return MAX_POWER_INDEX;
 	}
@@ -1768,18 +1771,26 @@ s8 PHY_GetTxPowerLimit(
 	if (Band == BAND_ON_2_4G) {
 		s8 limits[10] = {0}; u8 i = 0;
 		for (i = 0; i < MAX_REGULATION_NUM; i++)
-			limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth][rateSection][channel][RfPath];
+			limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth]
+							     [rateSection]
+							     [channel][RfPath];
 
-		powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
-			pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath];
+		powerLimit = (regulation == TXPWR_LMT_WW) ?
+			phy_GetWorldWideLimit(limits) :
+			pHalData->TxPwrLimit_2_4G[regulation][bandwidth]
+						 [rateSection][channel][RfPath];
 
 	} else if (Band == BAND_ON_5G) {
 		s8 limits[10] = {0}; u8 i = 0;
 		for (i = 0; i < MAX_REGULATION_NUM; ++i)
-			limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth][rateSection][channel][RfPath];
-
-		powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) :
-			pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath];
+			limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth]
+							   [rateSection]
+							   [channel][RfPath];
+
+		powerLimit = (regulation == TXPWR_LMT_WW) ?
+			phy_GetWorldWideLimit(limits) :
+			pHalData->TxPwrLimit_5G[regulation][bandwidth]
+					       [rateSection][channel][RfPath];
 	} else
 		DBG_871X("No power limit table of the specified band\n");
 
@@ -1789,22 +1800,20 @@ s8 PHY_GetTxPowerLimit(
 	if (Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX) {
 		if (bandwidth == 0 || bandwidth == 1) {
 			RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n",
-					  band, bandwidth, rateSection, RfPath));
+				 band, bandwidth,
+				 rateSection, RfPath));
 			if (rateSection == 2)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation]
-										[bandwidth][4][channelGroup][RfPath];
+				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][4][channelGroup][RfPath];
 			else if (rateSection == 4)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation]
-										[bandwidth][2][channelGroup][RfPath];
+				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][2][channelGroup][RfPath];
 			else if (rateSection == 3)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation]
-										[bandwidth][5][channelGroup][RfPath];
+				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][5][channelGroup][RfPath];
 			else if (rateSection == 5)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation]
-										[bandwidth][3][channelGroup][RfPath];
+				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][3][channelGroup][RfPath];
 		}
 	}
 	*/
+
 	/* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */
 	/*		regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */
 	return powerLimit;
@@ -3294,4 +3303,3 @@ void phy_free_filebuf(struct adapter *padapter)
 		vfree(pHalData->rf_tx_pwr_lmt);
 
 }
-
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 02/11] staging: rtl8723bs: Rename PHY_GetTxPowerLimit().
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 03/11] staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt() Quytelda Kahja
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Rename camel-case 'PHY_GetTxPowerLimit()' to 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c     | 6 +++---
 drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c    | 2 +-
 drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 5f727a7c16fd..4ab624f5ece0 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1612,9 +1612,9 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
 	return channelIndex;
 }
 
-s8 PHY_GetTxPowerLimit(struct adapter *Adapter, u32 RegPwrTblSel,
-		       enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
-		       u8 RfPath, u8 DataRate, u8 Channel)
+s8 phy_get_tx_pwr_lmt(struct adapter *Adapter, u32 RegPwrTblSel,
+		      enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
+		      u8 RfPath, u8 DataRate, u8 Channel)
 {
 	s16 band        = -1;
 	s16 regulation  = -1;
diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
index 50428f688859..78a4828ecb65 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c
@@ -688,7 +688,7 @@ u8 PHY_GetTxPowerIndex_8723B(
 	txPower = (s8) PHY_GetTxPowerIndexBase(padapter, RFPath, Rate, BandWidth, Channel, &bIn24G);
 	powerDiffByRate = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, Rate);
 
-	limit = PHY_GetTxPowerLimit(
+	limit = phy_get_tx_pwr_lmt(
 		padapter,
 		padapter->registrypriv.RegPwrTblSel,
 		(u8)(!bIn24G),
diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
index c5184315f82f..f841546584a7 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
@@ -177,7 +177,7 @@ u8 		Channel,
 	bool		*bIn24G
 	);
 
-s8 PHY_GetTxPowerLimit (struct adapter *adapter, u32 RegPwrTblSel,
+s8 phy_get_tx_pwr_lmt (struct adapter *adapter, u32 RegPwrTblSel,
 			enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
 u8 		RfPath,
 u8 		DataRate,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 03/11] staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt().
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 02/11] staging: rtl8723bs: Rename PHY_GetTxPowerLimit() Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 04/11] staging: rtl8723bs: Combine if statements with equivalent body Quytelda Kahja
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Change camel-case names to snake-case names; to avoid variable name
conflicts, rename table index variables to idx_*.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 .../staging/rtl8723bs/hal/hal_com_phycfg.c    | 200 +++++++++---------
 1 file changed, 105 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 4ab624f5ece0..7e27d7ff29fa 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1612,211 +1612,221 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
 	return channelIndex;
 }
 
-s8 phy_get_tx_pwr_lmt(struct adapter *Adapter, u32 RegPwrTblSel,
-		      enum BAND_TYPE Band, enum CHANNEL_WIDTH Bandwidth,
-		      u8 RfPath, u8 DataRate, u8 Channel)
+s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
+		      enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth,
+		      u8 rf_path, u8 data_rate, u8 channel)
 {
-	s16 band        = -1;
-	s16 regulation  = -1;
-	s16 bandwidth   = -1;
-	s16 rateSection = -1;
-	s16 channel     = -1;
-	s8 powerLimit = MAX_POWER_INDEX;
-	struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
-
-	if (((Adapter->registrypriv.RegEnableTxPowerLimit == 2) &&
-	     (pHalData->EEPROMRegulatory != 1)) ||
-	    (Adapter->registrypriv.RegEnableTxPowerLimit == 0))
+	s16 idx_band       = -1;
+	s16 idx_regulation = -1;
+	s16 idx_bandwidth  = -1;
+	s16 idx_rate_sctn  = -1;
+	s16 idx_channel    = -1;
+	s8 pwr_lmt = MAX_POWER_INDEX;
+	struct hal_com_data *hal_data = GET_HAL_DATA(adapter);
+
+	if (((adapter->registrypriv.RegEnableTxPowerLimit == 2) &&
+	     (hal_data->EEPROMRegulatory != 1)) ||
+	    (adapter->registrypriv.RegEnableTxPowerLimit == 0))
 		return MAX_POWER_INDEX;
 
-	switch (Adapter->registrypriv.RegPwrTblSel) {
+	switch (adapter->registrypriv.RegPwrTblSel) {
 	case 1:
-		regulation = TXPWR_LMT_ETSI;
+		idx_regulation = TXPWR_LMT_ETSI;
 		break;
 	case 2:
-		regulation = TXPWR_LMT_MKK;
+		idx_regulation = TXPWR_LMT_MKK;
 		break;
 	case 3:
-		regulation = TXPWR_LMT_FCC;
+		idx_regulation = TXPWR_LMT_FCC;
 		break;
 	case 4:
-		regulation = TXPWR_LMT_WW;
+		idx_regulation = TXPWR_LMT_WW;
 		break;
 	default:
-		regulation = (Band == BAND_ON_2_4G) ?
-			pHalData->Regulation2_4G :
-			pHalData->Regulation5G;
+		idx_regulation = (band_type == BAND_ON_2_4G) ?
+			hal_data->Regulation2_4G :
+			hal_data->Regulation5G;
 		break;
 	}
 
 	/* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", */
-	/*         Adapter->registrypriv.RegPwrTblSel, regulation); */
-
-	if (Band == BAND_ON_2_4G)
-		band = 0;
-	else if (Band == BAND_ON_5G)
-		band = 1;
-
-	if (Bandwidth == CHANNEL_WIDTH_20)
-		bandwidth = 0;
-	else if (Bandwidth == CHANNEL_WIDTH_40)
-		bandwidth = 1;
-	else if (Bandwidth == CHANNEL_WIDTH_80)
-		bandwidth = 2;
-	else if (Bandwidth == CHANNEL_WIDTH_160)
-		bandwidth = 3;
-
-	switch (DataRate) {
+	/*         adapter->registrypriv.RegPwrTblSel, idx_regulation); */
+
+	if (band_type == BAND_ON_2_4G)
+		idx_band = 0;
+	else if (band_type == BAND_ON_5G)
+		idx_band = 1;
+
+	if (bandwidth == CHANNEL_WIDTH_20)
+		idx_bandwidth = 0;
+	else if (bandwidth == CHANNEL_WIDTH_40)
+		idx_bandwidth = 1;
+	else if (bandwidth == CHANNEL_WIDTH_80)
+		idx_bandwidth = 2;
+	else if (bandwidth == CHANNEL_WIDTH_160)
+		idx_bandwidth = 3;
+
+	switch (data_rate) {
 	case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M:
-		rateSection = 0;
+		idx_rate_sctn = 0;
 		break;
 
 	case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M:
 	case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M:
-		rateSection = 1;
+		idx_rate_sctn = 1;
 		break;
 
 	case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3:
 	case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7:
-		rateSection = 2;
+		idx_rate_sctn = 2;
 		break;
 
 	case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11:
 	case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15:
-		rateSection = 3;
+		idx_rate_sctn = 3;
 		break;
 
 	case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19:
 	case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23:
-		rateSection = 4;
+		idx_rate_sctn = 4;
 		break;
 
 	case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27:
 	case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31:
-		rateSection = 5;
+		idx_rate_sctn = 5;
 		break;
 
 	case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2:
 	case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5:
 	case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8:
 	case MGN_VHT1SS_MCS9:
-		rateSection = 6;
+		idx_rate_sctn = 6;
 		break;
 
 	case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2:
 	case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5:
 	case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8:
 	case MGN_VHT2SS_MCS9:
-		rateSection = 7;
+		idx_rate_sctn = 7;
 		break;
 
 	case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2:
 	case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5:
 	case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8:
 	case MGN_VHT3SS_MCS9:
-		rateSection = 8;
+		idx_rate_sctn = 8;
 		break;
 
 	case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2:
 	case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5:
 	case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8:
 	case MGN_VHT4SS_MCS9:
-		rateSection = 9;
+		idx_rate_sctn = 9;
 		break;
 
 	default:
-		DBG_871X("Wrong rate 0x%x\n", DataRate);
+		DBG_871X("Wrong rate 0x%x\n", data_rate);
 		break;
 	}
 
-	if (Band == BAND_ON_5G && rateSection == 0)
+	if (band_type == BAND_ON_5G && idx_rate_sctn == 0)
                 DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
 
 	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  OFDM only exists in BW 20M */
-	if (rateSection == 1)
-		bandwidth = 0;
+	if (idx_rate_sctn == 1)
+		idx_bandwidth = 0;
 
 	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  CCK table will only be given in BW 20M */
-	if (rateSection == 0)
-		bandwidth = 0;
+	if (idx_rate_sctn == 0)
+		idx_bandwidth = 0;
 
 	/*  workaround for wrong indxe combination to obtain tx power limit, */
 	/*  HT on 80M will reference to HT on 40M */
-	if ((rateSection == 2 || rateSection == 3) &&
-	    Band == BAND_ON_5G && bandwidth == 2) {
-		bandwidth = 1;
+	if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) &&
+	    band_type == BAND_ON_5G && idx_bandwidth == 2) {
+		idx_bandwidth = 1;
 	}
 
-	if (Band == BAND_ON_2_4G)
+	if (band_type == BAND_ON_2_4G)
 		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G,
-							    Channel);
-	else if (Band == BAND_ON_5G)
+							    channel);
+	else if (band_type == BAND_ON_5G)
 		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G,
-							    Channel);
-	else if (Band == BAND_ON_BOTH) {
+							    channel);
+	else if (band_type == BAND_ON_BOTH) {
 		/*  BAND_ON_BOTH don't care temporarily */
 	}
 
-	if (band == -1 || regulation == -1 || bandwidth == -1 ||
-	    rateSection == -1 || channel == -1) {
+	if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 ||
+	    idx_rate_sctn == -1 || idx_channel == -1) {
 		/* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */
-		/*         band, regulation, bandwidth, RfPath, */
-		/*         rateSection, channelGroup); */
+		/*         idx_band, idx_regulation, idx_bandwidth, rf_path, */
+		/*         idx_rate_sctn, channel); */
 
 		return MAX_POWER_INDEX;
 	}
 
-	if (Band == BAND_ON_2_4G) {
+	if (band_type == BAND_ON_2_4G) {
 		s8 limits[10] = {0}; u8 i = 0;
 		for (i = 0; i < MAX_REGULATION_NUM; i++)
-			limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth]
-							     [rateSection]
-							     [channel][RfPath];
+			limits[i] = hal_data->TxPwrLimit_2_4G[i]
+							     [idx_bandwidth]
+							     [idx_rate_sctn]
+							     [idx_channel]
+							     [rf_path];
 
-		powerLimit = (regulation == TXPWR_LMT_WW) ?
+		pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ?
 			phy_GetWorldWideLimit(limits) :
-			pHalData->TxPwrLimit_2_4G[regulation][bandwidth]
-						 [rateSection][channel][RfPath];
+			hal_data->TxPwrLimit_2_4G[idx_regulation]
+						 [idx_bandwidth]
+						 [idx_rate_sctn]
+						 [idx_channel]
+						 [rf_path];
 
-	} else if (Band == BAND_ON_5G) {
+	} else if (band_type == BAND_ON_5G) {
 		s8 limits[10] = {0}; u8 i = 0;
 		for (i = 0; i < MAX_REGULATION_NUM; ++i)
-			limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth]
-							   [rateSection]
-							   [channel][RfPath];
+			limits[i] = hal_data->TxPwrLimit_5G[i]
+							   [idx_bandwidth]
+							   [idx_rate_sctn]
+							   [idx_channel]
+							   [rf_path];
 
-		powerLimit = (regulation == TXPWR_LMT_WW) ?
+		pwr_lmt = (idx_regulation == TXPWR_LMT_WW) ?
 			phy_GetWorldWideLimit(limits) :
-			pHalData->TxPwrLimit_5G[regulation][bandwidth]
-					       [rateSection][channel][RfPath];
+			hal_data->TxPwrLimit_5G[idx_regulation]
+					       [idx_bandwidth]
+					       [idx_rate_sctn]
+					       [idx_channel]
+					       [rf_path];
 	} else
 		DBG_871X("No power limit table of the specified band\n");
 
 	/*  combine 5G VHT & HT rate */
 	/*  5G 20M and 40M HT and VHT can cross reference */
 	/*
-	if (Band == BAND_ON_5G && powerLimit == MAX_POWER_INDEX) {
-		if (bandwidth == 0 || bandwidth == 1) {
+	if (band_type == BAND_ON_5G && pwr_lmt == MAX_POWER_INDEX) {
+		if (idx_bandwidth == 0 || idx_bandwidth == 1) {
 			RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n",
-				 band, bandwidth,
-				 rateSection, RfPath));
-			if (rateSection == 2)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][4][channelGroup][RfPath];
-			else if (rateSection == 4)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][2][channelGroup][RfPath];
-			else if (rateSection == 3)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][5][channelGroup][RfPath];
-			else if (rateSection == 5)
-				powerLimit = pHalData->TxPwrLimit_5G[regulation][bandwidth][3][channelGroup][RfPath];
+				 idx_band, idx_bandwidth,
+				 idx_rate_sctn, rf_path));
+			if (idx_rate_sctn == 2)
+				pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][4][idx_channel][rf_path];
+			else if (idx_rate_sctn == 4)
+				pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][2][idx_channel][rf_path];
+			else if (idx_rate_sctn == 3)
+				pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][5][idx_channel][rf_path];
+			else if (idx_rate_sctn == 5)
+				pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][3][idx_channel][rf_path];
 		}
 	}
 	*/
 
 	/* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */
-	/*		regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */
-	return powerLimit;
+	/*		idx_regulation, hal_data->CurrentBandType, bandwidth, rf_path, data_rate, channel, pwr_lmt); */
+	return pwr_lmt;
 }
 
 static void phy_CrossReferenceHTAndVHTTxPowerLimit(struct adapter *padapter)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 04/11] staging: rtl8723bs: Combine if statements with equivalent body.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 02/11] staging: rtl8723bs: Rename PHY_GetTxPowerLimit() Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 03/11] staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt() Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 05/11] staging: rtl8723bs: Remove empty else-if conditional Quytelda Kahja
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Two if statements that carry out the same operation can be combined with
a logical OR.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 7e27d7ff29fa..5d44aee44eb1 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1734,12 +1734,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 
 	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  OFDM only exists in BW 20M */
-	if (idx_rate_sctn == 1)
-		idx_bandwidth = 0;
-
-	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  CCK table will only be given in BW 20M */
-	if (idx_rate_sctn == 0)
+	if (idx_rate_sctn == 0 || idx_rate_sctn == 1)
 		idx_bandwidth = 0;
 
 	/*  workaround for wrong indxe combination to obtain tx power limit, */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 05/11] staging: rtl8723bs: Remove empty else-if conditional.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (2 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 04/11] staging: rtl8723bs: Combine if statements with equivalent body Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 06/11] staging: rtl8723bs: Move rate section index lookup to new function Quytelda Kahja
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

This else-if conditional block does nothing; remove it.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 5d44aee44eb1..6ae646ec3d06 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1751,9 +1751,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 	else if (band_type == BAND_ON_5G)
 		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G,
 							    channel);
-	else if (band_type == BAND_ON_BOTH) {
-		/*  BAND_ON_BOTH don't care temporarily */
-	}
 
 	if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 ||
 	    idx_rate_sctn == -1 || idx_channel == -1) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 06/11] staging: rtl8723bs: Move rate section index lookup to new function.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (3 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 05/11] staging: rtl8723bs: Remove empty else-if conditional Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 07/11] staging: rtl8723bs: Move bandwidth " Quytelda Kahja
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

The rate section lookup is a large switch statement in the middle of
'phy_get_tx_pwr_lmt()'; refactor this statement into it's own function
for increased readability.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 .../staging/rtl8723bs/hal/hal_com_phycfg.c    | 109 ++++++++----------
 1 file changed, 47 insertions(+), 62 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6ae646ec3d06..4b5219481b33 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1612,6 +1612,52 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
 	return channelIndex;
 }
 
+static s16 get_rate_sctn_idx(const u8 rate)
+{
+	switch (rate) {
+	case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M:
+		return 0;
+	case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M:
+	case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M:
+		return 1;
+	case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3:
+	case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7:
+		return 2;
+	case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11:
+	case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15:
+		return 3;
+	case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19:
+	case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23:
+		return 4;
+	case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27:
+	case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31:
+		return 5;
+	case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2:
+	case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5:
+	case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8:
+	case MGN_VHT1SS_MCS9:
+		return 6;
+	case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2:
+	case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5:
+	case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8:
+	case MGN_VHT2SS_MCS9:
+		return 7;
+	case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2:
+	case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5:
+	case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8:
+	case MGN_VHT3SS_MCS9:
+		return 8;
+	case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2:
+	case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5:
+	case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8:
+	case MGN_VHT4SS_MCS9:
+		return 9;
+	default:
+		DBG_871X("Wrong rate 0x%x\n", rate);
+		return -1;
+	}
+}
+
 s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 		      enum BAND_TYPE band_type, enum CHANNEL_WIDTH bandwidth,
 		      u8 rf_path, u8 data_rate, u8 channel)
@@ -1666,68 +1712,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 	else if (bandwidth == CHANNEL_WIDTH_160)
 		idx_bandwidth = 3;
 
-	switch (data_rate) {
-	case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M:
-		idx_rate_sctn = 0;
-		break;
-
-	case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M:
-	case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M:
-		idx_rate_sctn = 1;
-		break;
-
-	case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3:
-	case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7:
-		idx_rate_sctn = 2;
-		break;
-
-	case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11:
-	case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15:
-		idx_rate_sctn = 3;
-		break;
-
-	case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19:
-	case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23:
-		idx_rate_sctn = 4;
-		break;
-
-	case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27:
-	case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31:
-		idx_rate_sctn = 5;
-		break;
-
-	case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2:
-	case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5:
-	case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8:
-	case MGN_VHT1SS_MCS9:
-		idx_rate_sctn = 6;
-		break;
-
-	case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2:
-	case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5:
-	case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8:
-	case MGN_VHT2SS_MCS9:
-		idx_rate_sctn = 7;
-		break;
-
-	case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2:
-	case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5:
-	case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8:
-	case MGN_VHT3SS_MCS9:
-		idx_rate_sctn = 8;
-		break;
-
-	case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2:
-	case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5:
-	case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8:
-	case MGN_VHT4SS_MCS9:
-		idx_rate_sctn = 9;
-		break;
-
-	default:
-		DBG_871X("Wrong rate 0x%x\n", data_rate);
-		break;
-	}
+	idx_rate_sctn = get_rate_sctn_idx(data_rate);
 
 	if (band_type == BAND_ON_5G && idx_rate_sctn == 0)
                 DBG_871X("Wrong rate 0x%x: No CCK in 5G Band\n", DataRate);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 07/11] staging: rtl8723bs: Move bandwidth index lookup to new function.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (4 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 06/11] staging: rtl8723bs: Move rate section index lookup to new function Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 08/11] staging: rtl8723bs: Fix spelling mistake in comment Quytelda Kahja
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Factoring out the conditional lookup of bandwidth index into the power
limit table into it's own function simplifies the logic of
'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 .../staging/rtl8723bs/hal/hal_com_phycfg.c    | 26 ++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 4b5219481b33..6d8a07ac7bb3 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1612,6 +1612,22 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel)
 	return channelIndex;
 }
 
+static s16 get_bandwidth_idx(const enum CHANNEL_WIDTH bandwidth)
+{
+	switch (bandwidth) {
+	case CHANNEL_WIDTH_20:
+		return 0;
+	case CHANNEL_WIDTH_40:
+		return 1;
+	case CHANNEL_WIDTH_80:
+		return 2;
+	case CHANNEL_WIDTH_160:
+		return 3;
+	default:
+		return -1;
+	}
+}
+
 static s16 get_rate_sctn_idx(const u8 rate)
 {
 	switch (rate) {
@@ -1703,15 +1719,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 	else if (band_type == BAND_ON_5G)
 		idx_band = 1;
 
-	if (bandwidth == CHANNEL_WIDTH_20)
-		idx_bandwidth = 0;
-	else if (bandwidth == CHANNEL_WIDTH_40)
-		idx_bandwidth = 1;
-	else if (bandwidth == CHANNEL_WIDTH_80)
-		idx_bandwidth = 2;
-	else if (bandwidth == CHANNEL_WIDTH_160)
-		idx_bandwidth = 3;
-
+	idx_bandwidth = get_bandwidth_idx(bandwidth);
 	idx_rate_sctn = get_rate_sctn_idx(data_rate);
 
 	if (band_type == BAND_ON_5G && idx_rate_sctn == 0)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 08/11] staging: rtl8723bs: Fix spelling mistake in comment.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (5 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 07/11] staging: rtl8723bs: Move bandwidth " Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 09/11] staging: rtl8723bs: Merge conditionals with similar bodies Quytelda Kahja
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 6d8a07ac7bb3..dd097df86fa3 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1731,7 +1731,7 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 	if (idx_rate_sctn == 0 || idx_rate_sctn == 1)
 		idx_bandwidth = 0;
 
-	/*  workaround for wrong indxe combination to obtain tx power limit, */
+	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  HT on 80M will reference to HT on 40M */
 	if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) &&
 	    band_type == BAND_ON_5G && idx_bandwidth == 2) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 09/11] staging: rtl8723bs: Merge conditionals with similar bodies.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (6 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 08/11] staging: rtl8723bs: Fix spelling mistake in comment Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 10/11] staging: rtl8723bs: Merge workaround conditionals into single else-if Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 11/11] staging: rtl8723bs: Add missing curly braces on else statement Quytelda Kahja
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Two conditionals that set 'channel' based on 'band_type' in
'phy_get_tx_pwr_lmt()' can be simplified into one single-line conditional.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index dd097df86fa3..9e6dc238c028 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1738,12 +1738,8 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 		idx_bandwidth = 1;
 	}
 
-	if (band_type == BAND_ON_2_4G)
-		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G,
-							    channel);
-	else if (band_type == BAND_ON_5G)
-		channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G,
-							    channel);
+	if (band_type == BAND_ON_2_4G || band_type == BAND_ON_5G)
+		channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel);
 
 	if (idx_band == -1 || idx_regulation == -1 || idx_bandwidth == -1 ||
 	    idx_rate_sctn == -1 || idx_channel == -1) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 10/11] staging: rtl8723bs: Merge workaround conditionals into single else-if.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (7 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 09/11] staging: rtl8723bs: Merge conditionals with similar bodies Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  2018-06-17  5:30 ` [PATCH 11/11] staging: rtl8723bs: Add missing curly braces on else statement Quytelda Kahja
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

The if conditionals used to work around wrong TX power limit indices
can be condensed into a single if/else-if statement for more concise
expression.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 9e6dc238c028..0e49f0973c12 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1728,15 +1728,12 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 	/*  workaround for wrong index combination to obtain tx power limit, */
 	/*  OFDM only exists in BW 20M */
 	/*  CCK table will only be given in BW 20M */
+	/*  HT on 80M will reference to HT on 40M */
 	if (idx_rate_sctn == 0 || idx_rate_sctn == 1)
 		idx_bandwidth = 0;
-
-	/*  workaround for wrong index combination to obtain tx power limit, */
-	/*  HT on 80M will reference to HT on 40M */
-	if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) &&
-	    band_type == BAND_ON_5G && idx_bandwidth == 2) {
+	else if ((idx_rate_sctn == 2 || idx_rate_sctn == 3) &&
+		 (band_type == BAND_ON_5G) && (idx_bandwidth == 2))
 		idx_bandwidth = 1;
-	}
 
 	if (band_type == BAND_ON_2_4G || band_type == BAND_ON_5G)
 		channel = phy_GetChannelIndexOfTxPowerLimit(band_type, channel);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 11/11] staging: rtl8723bs: Add missing curly braces on else statement.
  2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
                   ` (8 preceding siblings ...)
  2018-06-17  5:30 ` [PATCH 10/11] staging: rtl8723bs: Merge workaround conditionals into single else-if Quytelda Kahja
@ 2018-06-17  5:30 ` Quytelda Kahja
  9 siblings, 0 replies; 11+ messages in thread
From: Quytelda Kahja @ 2018-06-17  5:30 UTC (permalink / raw)
  To: gregkh, hadess, hdegoede, Larry.Finger
  Cc: devel, linux-kernel, Quytelda Kahja

Fix 'braces {} should be used on all arms of this statement' coding
style problem in 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
---
 drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index 0e49f0973c12..0d2c61b67d0e 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -1780,8 +1780,9 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel,
 					       [idx_rate_sctn]
 					       [idx_channel]
 					       [rf_path];
-	} else
+	} else {
 		DBG_871X("No power limit table of the specified band\n");
+	}
 
 	/*  combine 5G VHT & HT rate */
 	/*  5G 20M and 40M HT and VHT can cross reference */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-06-17  5:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-17  5:30 [PATCH 01/11] staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()' Quytelda Kahja
2018-06-17  5:30 ` [PATCH 02/11] staging: rtl8723bs: Rename PHY_GetTxPowerLimit() Quytelda Kahja
2018-06-17  5:30 ` [PATCH 03/11] staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt() Quytelda Kahja
2018-06-17  5:30 ` [PATCH 04/11] staging: rtl8723bs: Combine if statements with equivalent body Quytelda Kahja
2018-06-17  5:30 ` [PATCH 05/11] staging: rtl8723bs: Remove empty else-if conditional Quytelda Kahja
2018-06-17  5:30 ` [PATCH 06/11] staging: rtl8723bs: Move rate section index lookup to new function Quytelda Kahja
2018-06-17  5:30 ` [PATCH 07/11] staging: rtl8723bs: Move bandwidth " Quytelda Kahja
2018-06-17  5:30 ` [PATCH 08/11] staging: rtl8723bs: Fix spelling mistake in comment Quytelda Kahja
2018-06-17  5:30 ` [PATCH 09/11] staging: rtl8723bs: Merge conditionals with similar bodies Quytelda Kahja
2018-06-17  5:30 ` [PATCH 10/11] staging: rtl8723bs: Merge workaround conditionals into single else-if Quytelda Kahja
2018-06-17  5:30 ` [PATCH 11/11] staging: rtl8723bs: Add missing curly braces on else statement Quytelda Kahja

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.