Remove several variables that are zero from struct r8192_priv
cover Remove several variables that are zero from struct r8192_priv
The arrays EEPROMRfACCKChnl1TxPwLevel, EEPROMRfAOfdmChnlTxPwLevel, EEPROMRfCCCKChnl1TxPwLevel, EEPROMRfCOfdmChnlTxPwLevel are initialized to zero and never changed. These arrays are used to initialize other variables that are then also zero. Remove several variables set to zero to avoid camelCase and to remove dead code.
Tested with rtl8192e (But most of this code is not executed on my hardware) Transferred this patch over wlan connection of rtl8192e
Philipp Hortmann (6):
staging: rtl8192e: Combine three loops to one to init tx_pwr_level_...
staging: rtl8192e: Init tx_pwr_level_cck_a and friends directly
staging: rtl8192e: Remove zeroed arrays tx_pwr_level_cck_a and friends
staging: rtl8192e: Remove ant_pwr_diff which is always zero
staging: rtl8192e: Remove u4RegValue which is always zero
staging: rtl8192e: Remove repeated set to zero of powerlevel and
friend
.../staging/rtl8192e/rtl8192e/r8192E_dev.c | 31 ------------------- .../staging/rtl8192e/rtl8192e/r8192E_phy.c | 24 ++------------ drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 8 ----- 3 files changed, 3 insertions(+), 60 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/6 staging: rtl8192e: Combine three loops to one to init tx_pwr_level_...
The arrays EEPROMRfACCKChnl1TxPwLevel, EEPROMRfAOfdmChnlTxPwLevel, EEPROMRfCCCKChnl1TxPwLevel, EEPROMRfCOfdmChnlTxPwLevel are initialized to zero and never changed. The three loops contain the same code. Only the index of the upper named arrays go from 0 to 2. Therefore the three loops can be combined to one loop from 0 to 13 which removes useless code.
--- .../staging/rtl8192e/rtl8192e/r8192E_dev.c | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +1 -21
@@ -426,7 +426,7 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) 0xf0) >> 4; }else if (priv->epromtype ==EEPROM_93C56 ) { -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <14 ; i++) { priv->tx_pwr_level_cck_a[i] = priv->EEPROMRfACCKChnl1TxPwLevel[0 ]; priv->tx_pwr_level_ofdm_24g_a[i] =
@@ -436,26 +436,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->tx_pwr_level_ofdm_24g_c[i] = priv->EEPROMRfCOfdmChnlTxPwLevel[0 ]; } -for (i =3 ; i <9 ; i++) { - priv->tx_pwr_level_cck_a[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[1 ]; - priv->tx_pwr_level_ofdm_24g_a[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[1 ]; - priv->tx_pwr_level_cck_c[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[1 ]; - priv->tx_pwr_level_ofdm_24g_c[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[1 ]; - } -for (i =9 ; i <14 ; i++) { - priv->tx_pwr_level_cck_a[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[2 ]; - priv->tx_pwr_level_ofdm_24g_a[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[2 ]; - priv->tx_pwr_level_cck_c[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[2 ]; - priv->tx_pwr_level_ofdm_24g_c[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[2 ]; - } priv->legacy_ht_tx_pwr_diff = priv->eeprom_legacy_ht_tx_pwr_diff; priv->antenna_tx_pwr_diff[0 ] =0 ;
Signature · 1 line
2.39.0
PATCH 2/6 staging: rtl8192e: Init tx_pwr_level_cck_a and friends directly
In reply to Philipp HortmannThe arrays EEPROMRfACCKChnl1TxPwLevel, EEPROMRfAOfdmChnlTxPwLevel, EEPROMRfCCCKChnl1TxPwLevel, EEPROMRfCOfdmChnlTxPwLevel are initialized to zero and never changed. Delete the arrays and set the variables directly to zero to avoid CamelCase which is not accepted by checkpatch.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 12 ++++-------- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 4 ---- 2 files changed, 4 insertions(+), 12 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +4 -8
@@ -427,14 +427,10 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) }else if (priv->epromtype ==EEPROM_93C56 ) {for (i =0 ; i <14 ; i++) { - priv->tx_pwr_level_cck_a[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[0 ]; - priv->tx_pwr_level_ofdm_24g_a[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[0 ]; - priv->tx_pwr_level_cck_c[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[0 ]; - priv->tx_pwr_level_ofdm_24g_c[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[0 ]; + priv->tx_pwr_level_cck_a[i] =0 ; + priv->tx_pwr_level_ofdm_24g_a[i] =0 ; + priv->tx_pwr_level_cck_c[i] =0 ; + priv->tx_pwr_level_ofdm_24g_c[i] =0 ; } priv->legacy_ht_tx_pwr_diff = priv->eeprom_legacy_ht_tx_pwr_diff;
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +0 -4
@@ -423,10 +423,6 @@ struct r8192_priv {u8 eeprom_tx_pwr_level_cck[14 ];u8 eeprom_tx_pwr_level_ofdm24g[14 ]; -u8 EEPROMRfACCKChnl1TxPwLevel[3 ]; -u8 EEPROMRfAOfdmChnlTxPwLevel[3 ]; -u8 EEPROMRfCCCKChnl1TxPwLevel[3 ]; -u8 EEPROMRfCOfdmChnlTxPwLevel[3 ];u16 eeprom_ant_pwr_diff;u8 eeprom_thermal_meter;u8 eeprom_crystal_cap;
Signature · 1 line
2.39.0
PATCH 3/6 staging: rtl8192e: Remove zeroed arrays tx_pwr_level_cck_a and friends
In reply to Philipp HortmannThe arrays tx_pwr_level_cck_a, tx_pwr_level_ofdm_24g_a, tx_pwr_level_cck_c and tx_pwr_level_ofdm_24g_c are initialized to zero and never changed. Delete the upper named arrays and set the variables directly to zero to avoid useless code.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 7 ------- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 11 +++++------ drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 4 ---- 3 files changed, 5 insertions(+), 17 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +0 -7
@@ -425,13 +425,6 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->thermal_meter[1 ] = (priv->eeprom_thermal_meter &0xf0 ) >>4 ; }else if (priv->epromtype ==EEPROM_93C56 ) { - -for (i =0 ; i <14 ; i++) { - priv->tx_pwr_level_cck_a[i] =0 ; - priv->tx_pwr_level_ofdm_24g_a[i] =0 ; - priv->tx_pwr_level_cck_c[i] =0 ; - priv->tx_pwr_level_ofdm_24g_c[i] =0 ; - } priv->legacy_ht_tx_pwr_diff = priv->eeprom_legacy_ht_tx_pwr_diff; priv->antenna_tx_pwr_diff[0 ] =0 ;
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +5 -6
@@ -594,14 +594,13 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g[channel -1 ]; }else if (priv->epromtype ==EEPROM_93C56 ) {if (priv->rf_type ==RF_1T2R ) { - powerlevel = priv->tx_pwr_level_cck_c[channel -1 ]; - powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g_c[channel -1 ]; + powerlevel =0 ; + powerlevelOFDM24G =0 ; }else if (priv->rf_type ==RF_2T4R ) { - powerlevel = priv->tx_pwr_level_cck_a[channel -1 ]; - powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g_a[channel -1 ]; + powerlevel =0 ; + powerlevelOFDM24G =0 ; - ant_pwr_diff = priv->tx_pwr_level_ofdm_24g_c[channel -1 ] - - priv->tx_pwr_level_ofdm_24g_a[channel -1 ]; + ant_pwr_diff =0 ; ant_pwr_diff &=0xf ;
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +0 -4
@@ -464,11 +464,7 @@ struct r8192_priv {u32 mcs_tx_pwr_level_org_offset[6 ];u8 tx_pwr_level_cck[14 ]; -u8 tx_pwr_level_cck_a[14 ]; -u8 tx_pwr_level_cck_c[14 ];u8 tx_pwr_level_ofdm_24g[14 ]; -u8 tx_pwr_level_ofdm_24g_a[14 ]; -u8 tx_pwr_level_ofdm_24g_c[14 ];u8 legacy_ht_tx_pwr_diff;u8 antenna_tx_pwr_diff[3 ];
Signature · 1 line
2.39.0
PATCH 4/6 staging: rtl8192e: Remove ant_pwr_diff which is always zero
In reply to Philipp Hortmannant_pwr_diff is set to zero and then masked which will always result in zero. Remove ant_pwr_diff and use zero direct as it is just useless code.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -6
@@ -586,7 +586,6 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) {struct r8192_priv *priv =rtllib_priv (dev);u8 powerlevel =0 , powerlevelOFDM24G =0 ; -s8 ant_pwr_diff;u32 u4RegValue;if (priv->epromtype ==EEPROM_93C46 ) {
@@ -600,12 +599,8 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) powerlevel =0 ; powerlevelOFDM24G =0 ; - ant_pwr_diff =0 ; - - ant_pwr_diff &=0xf ; - priv->antenna_tx_pwr_diff[2 ] =0 ; - priv->antenna_tx_pwr_diff[1 ] = (u8)(ant_pwr_diff); + priv->antenna_tx_pwr_diff[1 ] =0 ; priv->antenna_tx_pwr_diff[0 ] =0 ; u4RegValue = priv->antenna_tx_pwr_diff[2] << 8 |
Signature · 1 line
2.39.0
PATCH 5/6 staging: rtl8192e: Remove u4RegValue which is always zero
In reply to Philipp HortmannAs the array antenna_tx_pwr_diff is always zero, u4RegValue is always set to zero. Replace u4RegValue to avoid CamelCase which is not accepted by checkpatch.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -7
@@ -586,7 +586,6 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) {struct r8192_priv *priv =rtllib_priv (dev);u8 powerlevel =0 , powerlevelOFDM24G =0 ; -u32 u4RegValue;if (priv->epromtype ==EEPROM_93C46 ) { powerlevel = priv->tx_pwr_level_cck[channel -1 ];
@@ -603,13 +602,8 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) priv->antenna_tx_pwr_diff[1 ] =0 ; priv->antenna_tx_pwr_diff[0 ] =0 ; - u4RegValue = priv->antenna_tx_pwr_diff[2 ] <<8 | - priv->antenna_tx_pwr_diff[1 ] <<4 | - priv->antenna_tx_pwr_diff[0 ]; -rtl92e_set_bb_reg (dev, rFPGA0_TxGainStage, - (bXBTxAGC|bXCTxAGC|bXDTxAGC), - u4RegValue); + (bXBTxAGC | bXCTxAGC | bXDTxAGC),0 ); } }switch (priv->rf_chip) {
Signature · 1 line
2.39.0
PATCH 6/6 staging: rtl8192e: Remove repeated set to zero of powerlevel and friend
In reply to Philipp HortmannVariables powerlevel and powerlevelOFDM24G are initialized to zero and unchanged. No reason to set them to zero again. Remove dead code.
--- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +1 -7
@@ -591,13 +591,7 @@ void rtl92e_set_tx_power(struct net_device *dev, u8 channel) powerlevel = priv->tx_pwr_level_cck[channel -1 ]; powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g[channel -1 ]; }else if (priv->epromtype ==EEPROM_93C56 ) { -if (priv->rf_type ==RF_1T2R ) { - powerlevel =0 ; - powerlevelOFDM24G =0 ; - }else if (priv->rf_type ==RF_2T4R ) { - powerlevel =0 ; - powerlevelOFDM24G =0 ; - +if (priv->rf_type ==RF_2T4R ) { priv->antenna_tx_pwr_diff[2 ] =0 ; priv->antenna_tx_pwr_diff[1 ] =0 ; priv->antenna_tx_pwr_diff[0 ] =0 ;
Signature · 1 line
2.39.0