[PATCH v2 2/3] staging: rtl8723bs: access TxPowerByRateBase2_4G directly
From: Leonardo Martins Martins
Date: Fri Oct 02 2026 - 00:09:03 EST
In phy_tx_power_limit_to_index(), pwr_base is acquired from
TxPowerByRateBase2_4G using rs, which itself is an iterator between
0 and 2, but it's accessed by using an if-else chain that then passes
the equivalent enum constant to PHY_GetTxPowerByRateBase(), which
checks RfPath against RF_PATH_MAX (which is already done by the loop),
then uses a switch-case statement on the enum to access
TxPowerByRateBase2_4G with the original value of rs.
Remove the redundant if-else, the call to PHY_GetTxPowerByRateBase() and
access it directly. Also remove PHY_GetTxPowerByRateBase() since those
were its only usages.
Signed-off-by: Leonardo Martins Martins <dev.lmmrtns@xxxxxxxxx>
---
drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 37 ++--------------------
drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 3 --
2 files changed, 3 insertions(+), 37 deletions(-)
diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
index e98e8a936630cbb6c336ad923234781e718b5c10..937441aa7dfee50857d37e0d0aa1415037b8cc60 100644
--- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
+++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c
@@ -10,32 +10,6 @@
#include <linux/kernel.h>
#include <linux/string.h>
-u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath,
- enum rate_section RateSection)
-{
- struct hal_com_data *pHalData = GET_HAL_DATA(Adapter);
- u8 value = 0;
-
- if (RfPath >= RF_PATH_MAX)
- return 0;
-
- switch (RateSection) {
- case CCK:
- value = pHalData->TxPwrByRateBase2_4G[RfPath][0];
- break;
- case OFDM:
- value = pHalData->TxPwrByRateBase2_4G[RfPath][1];
- break;
- case HT_MCS0_MCS7:
- value = pHalData->TxPwrByRateBase2_4G[RfPath][2];
- break;
- default:
- break;
- }
-
- return value;
-}
-
static void
phy_SetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath,
enum rate_section RateSection, u8 Value)
@@ -755,14 +729,9 @@ void phy_tx_power_limit_to_index(struct adapter *adapter)
tmp_pwr_lmt = hal_data->TxPwrLimit_2_4G[regulation][bw][rs][channel][RF_PATH_A];
for (path = RF_PATH_A; path < MAX_RF_PATH_NUM; ++path) {
- if (hal_data->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) {
- if (rs == 2) /* HT 1T */
- pwr_base = PHY_GetTxPowerByRateBase(adapter, path, HT_MCS0_MCS7);
- else if (rs == 1) /* OFDM */
- pwr_base = PHY_GetTxPowerByRateBase(adapter, path, OFDM);
- else if (rs == 0) /* CCK */
- pwr_base = PHY_GetTxPowerByRateBase(adapter, path, CCK);
- } else
+ if (hal_data->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE)
+ pwr_base = hal_data->TxPwrByRateBase2_4G[path][rs];
+ else
pwr_base = r->reg_power_base * 2;
if (tmp_pwr_lmt != MAX_POWER_INDEX) {
diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
index a20b4c233de8128fe20e41dee2b303a4662f4de4..ec17e093d8832460ada94878433600063a2b4eab 100644
--- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
+++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h
@@ -54,9 +54,6 @@ struct bb_register_def {
};
-u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath,
- enum rate_section RateSection);
-
u8 PHY_GetRateSectionIndexOfTxPowerByRate(struct adapter *padapter, u32 RegAddr,
u32 BitMask);
--
2.47.3