staging: rtlwifi: Remove unnecessary conditions
PATCH 1/1 staging: rtlwifi: Remove unnecessary conditions
Remove conditions with no effect at four different sections. Issues found by Coccinelle's semantic patch results for cond_no_effect.cocci. Edit two statements to keep expressions on one line--one from Julia's feedback. Eliminate checkpatch result, a line should not end with a parenthesis.
--- drivers/staging/rtlwifi/phydm/phydm_debug.c | 35 +++++++------------ drivers/staging/rtlwifi/phydm/phydm_dig.c | 9 ++--- .../staging/rtlwifi/phydm/phydm_hwconfig.c | 6 ++-- drivers/staging/rtlwifi/phydm/phydm_psd.c | 7 +--- 4 files changed, 17 insertions(+), 40 deletions(-)
drivers/staging/rtlwifi/phydm/phydm_debug.c +12 -23
@@ -140,26 +140,17 @@ static inline void phydm_print_csi(struct phy_dm_struct *dm, u32 used, dword_h =odm_get_bb_reg (dm,0xF74 ,MASKDWORD ); dword_l =odm_get_bb_reg (dm,0xF5C ,MASKDWORD ); -if (index %2 ==0 ) -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); -else -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); +PHYDM_SNPRINTF (output + used, + out_len - used, +"%02x %02x %02x %02x %02x %02x %02x %02x\n" , + dword_l &MASKBYTE0 , + (dword_l &MASKBYTE1 ) >>8 , + (dword_l &MASKBYTE2 ) >>16 , + (dword_l &MASKBYTE3 ) >>24 , + dword_h &MASKBYTE0 , + (dword_h &MASKBYTE1 ) >>8 , + (dword_h &MASKBYTE2 ) >>16 , + (dword_h &MASKBYTE3 ) >>24 ); } }
@@ -168,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level =ODM_DBG_TRACE ; dm->fw_debug_components =0 ; - dm->debug_components = - -0 ; + dm->debug_components =0 ; dm->fw_buff_is_enpty = true; dm->pre_c2h_seq =0 ;
drivers/staging/rtlwifi/phydm/phydm_dig.c +2 -7
@@ -599,13 +599,8 @@ void odm_dig_init(void *dm_void) (DM_DIG_MAX_PAUSE_TYPE + 1)); dig_tab->pause_cckpd_level =0 ; -if (dm->board_type & (ODM_BOARD_EXT_PA |ODM_BOARD_EXT_LNA )) { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - }else { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - } + dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; + dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; dig_tab->enable_adjust_big_jump =1 ;if (dm->support_ic_type &ODM_RTL8822B ) {
drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +2 -4
@@ -45,8 +45,8 @@ static u32 phydm_process_rssi_pwdb(struct phy_dm_struct *dm,u32 weighting =0 , undecorated_smoothed_pwdb;/* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ -if (entry->rssi_stat.ofdm_pkt == -64 ) {/* speed up when all packets are OFDM*/ +if (entry->rssi_stat.ofdm_pkt ==64 ) { +/* speed up when all packets are OFDM*/ undecorated_smoothed_pwdb = undecorated_smoothed_ofdm; ODM_RT_TRACE(dm, ODM_COMP_RSSI_MONITOR, "PWDB_0[%d] = (( %d ))\n", pktinfo->station_id,
@@ -1719,8 +1719,6 @@ static void phydm_get_rx_phy_status_type2(struct phy_dm_struct *dm, ODM_RTL8710B)) { /* JJ ADD 20161014 */if (rxsc ==3 ) bw =ODM_BW40M ; -else if ((rxsc ==1 ) || (rxsc ==2 )) - bw =ODM_BW20M ;else bw =ODM_BW20M ; }
drivers/staging/rtlwifi/phydm/phydm_psd.c +1 -6
@@ -336,12 +336,7 @@ void phydm_psd_init(void *dm_void)2 ;/*2b'11: 20MHz, 2b'10: 40MHz, 2b'01: 80MHz */ } -if (dm->support_ic_type ==ODM_RTL8812 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else if (dm->support_ic_type ==ODM_RTL8821 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else - dm_psd_table->psd_pwr_common_offset =0 ; + dm_psd_table->psd_pwr_common_offset =0 ;phydm_psd_para_setting (dm,1 ,2 ,3 ,128 ,0 ,0 ,7 ,0 );/*phydm_psd(dm, 0x3c, 0, 127);*/ /* target at -50dBm */
Signature · 1 line
2.17.1
Quoted 56 lines · Maya Nakamura
Remove conditions with no effect at four different sections. Issues found by Coccinelle's semantic patch results for
cond_no_effect.cocci. Edit two statements to keep expressions on one line--one from Julia's feedback. Eliminate checkpatch result, a line should not end with a parenthesis.Signed-off-by Maya Nakamura <[email protected]>--- drivers/staging/rtlwifi/phydm/phydm_debug.c | 35 +++++++------------ drivers/staging/rtlwifi/phydm/phydm_dig.c | 9 ++--- .../staging/rtlwifi/phydm/phydm_hwconfig.c | 6 ++-- drivers/staging/rtlwifi/phydm/phydm_psd.c | 7 +--- 4 files changed, 17 insertions(+), 40 deletions(-)drivers/staging/rtlwifi/phydm/phydm_debug.c +11
-20@@ -140,26 +140,17 @@ static inline void phydm_print_csi(struct phy_dm_struct *dm, u32 used, dword_h =odm_get_bb_reg (dm,0xF74 ,MASKDWORD ); dword_l =odm_get_bb_reg (dm,0xF5C ,MASKDWORD ); -if (index %2 ==0 ) -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); -else -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); +PHYDM_SNPRINTF (output + used, + out_len - used, +"%02x %02x %02x %02x %02x %02x %02x %02x\n" , + dword_l &MASKBYTE0 , + (dword_l &MASKBYTE1 ) >>8 , + (dword_l &MASKBYTE2 ) >>16 , + (dword_l &MASKBYTE3 ) >>24 , + dword_h &MASKBYTE0 , + (dword_h &MASKBYTE1 ) >>8 , + (dword_h &MASKBYTE2 ) >>16 , + (dword_h &MASKBYTE3 ) >>24 ); } }
drivers/staging/rtlwifi/phydm/phydm_debug.c void phydm_init_debug_setting(struct phy_dm_struct *dm) · line 162
Quoted 7 lines
drivers/staging/rtlwifi/phydm/phydm_debug.c +1
-3@@ -168,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level =ODM_DBG_TRACE ; dm->fw_debug_components =0 ; - dm->debug_components = - -0 ; + dm->debug_components =0 ;
Does this belong here? I don't see an if nearby. You should make a series if you want to do two different things on the same file.
julia
Quoted 75 lines
drivers/staging/rtlwifi/phydm/phydm_debug.c +0
-0dm->fw_buff_is_enpty = true; dm->pre_c2h_seq =0 ;drivers/staging/rtlwifi/phydm/phydm_dig.c +2
-7@@ -599,13 +599,8 @@ void odm_dig_init(void *dm_void) (DM_DIG_MAX_PAUSE_TYPE + 1)); dig_tab->pause_cckpd_level =0 ; -if (dm->board_type & (ODM_BOARD_EXT_PA |ODM_BOARD_EXT_LNA )) { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - }else { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - } + dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; + dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; dig_tab->enable_adjust_big_jump =1 ;if (dm->support_ic_type &ODM_RTL8822B ) {drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +2
-4@@ -45,8 +45,8 @@ static u32 phydm_process_rssi_pwdb(struct phy_dm_struct *dm,u32 weighting =0 , undecorated_smoothed_pwdb;/* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ -if (entry->rssi_stat.ofdm_pkt == -64 ) {/* speed up when all packets are OFDM*/ +if (entry->rssi_stat.ofdm_pkt ==64 ) { +/* speed up when all packets are OFDM*/ undecorated_smoothed_pwdb = undecorated_smoothed_ofdm; ODM_RT_TRACE(dm, ODM_COMP_RSSI_MONITOR, "PWDB_0[%d] = (( %d ))\n", pktinfo->station_id,@@ -1719,8 +1719,6 @@ static void phydm_get_rx_phy_status_type2(struct phy_dm_struct *dm, ODM_RTL8710B)) { /* JJ ADD 20161014 */if (rxsc ==3 ) bw =ODM_BW40M ; -else if ((rxsc ==1 ) || (rxsc ==2 )) - bw =ODM_BW20M ;else bw =ODM_BW20M ; }drivers/staging/rtlwifi/phydm/phydm_psd.c +1
-7@@ -336,12 +336,7 @@ void phydm_psd_init(void *dm_void)2 ;/*2b'11: 20MHz, 2b'10: 40MHz, 2b'01: 80MHz */ } -if (dm->support_ic_type ==ODM_RTL8812 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else if (dm->support_ic_type ==ODM_RTL8821 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else - dm_psd_table->psd_pwr_common_offset =0 ; + dm_psd_table->psd_pwr_common_offset =0 ;phydm_psd_para_setting (dm,1 ,2 ,3 ,128 ,0 ,0 ,7 ,0 );/*phydm_psd(dm, 0x3c, 0, 127);*/ /* target at -50dBm */ --2.17.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181030063636.GA5098%40k-vBox.
For more options, visit https://groups.google.com/d/optout.
Quoted 72 lines · Julia Lawall
Quoted 56 lines · Maya Nakamura
Remove conditions with no effect at four different sections. Issues found by Coccinelle's semantic patch results for
cond_no_effect.cocci. Edit two statements to keep expressions on one line--one from Julia's feedback. Eliminate checkpatch result, a line should not end with a parenthesis.Signed-off-by Maya Nakamura <[email protected]>--- drivers/staging/rtlwifi/phydm/phydm_debug.c | 35 +++++++------------ drivers/staging/rtlwifi/phydm/phydm_dig.c | 9 ++--- .../staging/rtlwifi/phydm/phydm_hwconfig.c | 6 ++-- drivers/staging/rtlwifi/phydm/phydm_psd.c | 7 +--- 4 files changed, 17 insertions(+), 40 deletions(-)drivers/staging/rtlwifi/phydm/phydm_debug.c +11
-20@@ -140,26 +140,17 @@ static inline void phydm_print_csi(struct phy_dm_struct *dm, u32 used, dword_h =odm_get_bb_reg (dm,0xF74 ,MASKDWORD ); dword_l =odm_get_bb_reg (dm,0xF5C ,MASKDWORD ); -if (index %2 ==0 ) -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); -else -PHYDM_SNPRINTF ( - output + used, out_len - used, -"%02x %02x %02x %02x %02x %02x %02x %02x\n" , - dword_l &MASKBYTE0 , (dword_l &MASKBYTE1 ) >>8 , - (dword_l &MASKBYTE2 ) >>16 , - (dword_l &MASKBYTE3 ) >>24 , - dword_h &MASKBYTE0 , (dword_h &MASKBYTE1 ) >>8 , - (dword_h &MASKBYTE2 ) >>16 , - (dword_h &MASKBYTE3 ) >>24 ); +PHYDM_SNPRINTF (output + used, + out_len - used, +"%02x %02x %02x %02x %02x %02x %02x %02x\n" , + dword_l &MASKBYTE0 , + (dword_l &MASKBYTE1 ) >>8 , + (dword_l &MASKBYTE2 ) >>16 , + (dword_l &MASKBYTE3 ) >>24 , + dword_h &MASKBYTE0 , + (dword_h &MASKBYTE1 ) >>8 , + (dword_h &MASKBYTE2 ) >>16 , + (dword_h &MASKBYTE3 ) >>24 ); } }drivers/staging/rtlwifi/phydm/phydm_debug.c void phydm_init_debug_setting(struct phy_dm_struct *dm) · line 162
Quoted 7 lines
drivers/staging/rtlwifi/phydm/phydm_debug.c +1
-3@@ -168,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level =ODM_DBG_TRACE ; dm->fw_debug_components =0 ; - dm->debug_components = - -0 ; + dm->debug_components =0 ;Does this belong here? I don't see an if nearby. You should make a series if you want to do two different things on the same file.
Quoted 1 line
julia
Thank you, Julia, for reviewing my submission! I will separate different types of fixes into their own patches and resend these.
Maya
Quoted 75 lines
Quoted 75 lines
drivers/staging/rtlwifi/phydm/phydm_debug.c +0
-0dm->fw_buff_is_enpty = true; dm->pre_c2h_seq =0 ;drivers/staging/rtlwifi/phydm/phydm_dig.c +2
-7@@ -599,13 +599,8 @@ void odm_dig_init(void *dm_void) (DM_DIG_MAX_PAUSE_TYPE + 1)); dig_tab->pause_cckpd_level =0 ; -if (dm->board_type & (ODM_BOARD_EXT_PA |ODM_BOARD_EXT_LNA )) { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - }else { - dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; - dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; - } + dig_tab->rx_gain_range_max =DM_DIG_MAX_NIC ; + dig_tab->rx_gain_range_min =DM_DIG_MIN_NIC ; dig_tab->enable_adjust_big_jump =1 ;if (dm->support_ic_type &ODM_RTL8822B ) {drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +2
-4@@ -45,8 +45,8 @@ static u32 phydm_process_rssi_pwdb(struct phy_dm_struct *dm,u32 weighting =0 , undecorated_smoothed_pwdb;/* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ -if (entry->rssi_stat.ofdm_pkt == -64 ) {/* speed up when all packets are OFDM*/ +if (entry->rssi_stat.ofdm_pkt ==64 ) { +/* speed up when all packets are OFDM*/ undecorated_smoothed_pwdb = undecorated_smoothed_ofdm; ODM_RT_TRACE(dm, ODM_COMP_RSSI_MONITOR, "PWDB_0[%d] = (( %d ))\n", pktinfo->station_id,@@ -1719,8 +1719,6 @@ static void phydm_get_rx_phy_status_type2(struct phy_dm_struct *dm, ODM_RTL8710B)) { /* JJ ADD 20161014 */if (rxsc ==3 ) bw =ODM_BW40M ; -else if ((rxsc ==1 ) || (rxsc ==2 )) - bw =ODM_BW20M ;else bw =ODM_BW20M ; }drivers/staging/rtlwifi/phydm/phydm_psd.c +1
-7@@ -336,12 +336,7 @@ void phydm_psd_init(void *dm_void)2 ;/*2b'11: 20MHz, 2b'10: 40MHz, 2b'01: 80MHz */ } -if (dm->support_ic_type ==ODM_RTL8812 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else if (dm->support_ic_type ==ODM_RTL8821 ) - dm_psd_table->psd_pwr_common_offset =0 ; -else - dm_psd_table->psd_pwr_common_offset =0 ; + dm_psd_table->psd_pwr_common_offset =0 ;phydm_psd_para_setting (dm,1 ,2 ,3 ,128 ,0 ,0 ,7 ,0 );/*phydm_psd(dm, 0x3c, 0, 127);*/ /* target at -50dBm */ --2.17.1
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20181030063636.GA5098%40k-vBox.
For more options, visit https://groups.google.com/d/optout.
Quoted 15 lines · Maya Nakamura
Quoted 14 lines · Julia Lawall
drivers/staging/rtlwifi/phydm/phydm_debug.c void phydm_init_debug_setting(struct phy_dm_struct *dm) · line 162
Quoted 8 lines · Maya Nakamura
drivers/staging/rtlwifi/phydm/phydm_debug.c +1
-3@@ -168,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level =ODM_DBG_TRACE ; dm->fw_debug_components =0 ; - dm->debug_components = - -0 ; + dm->debug_components =0 ;Does this belong here? I don't see an if nearby. You should make a series if you want to do two different things on the same file.
Quoted 4 lines
Quoted 1 line
julia
Thank you, Julia, for reviewing my submission! I will separate different types of fixes into their own patches and resend these.
Hi Maya,
I'm guessing that while you were working on your original plan to remove unnecessary conditions you saw the weird looking piece of code above and decided to fix it as well. As a result, while you dealt nicely with this cleanup, you ended up with unrelated changes in the same patch.
An easy way to work around it is the '-p' flag to 'git add'. This flag lets you interactively select hunks to stage in git; you don't have to 'git add' and entire file, but can just add parts of it.
This way, you stage only the relevant hunks and 'git commit' them when you're ready. Rinse and repeat for every set of hunks that represents a single logical change.
--
Thanks,
Sasha
Quoted 32 lines · Sasha Levin
Quoted 15 lines · Maya Nakamura
Quoted 14 lines · Julia Lawall
drivers/staging/rtlwifi/phydm/phydm_debug.c void phydm_init_debug_setting(struct phy_dm_struct *dm) · line 162
Quoted 8 lines · Maya Nakamura
drivers/staging/rtlwifi/phydm/phydm_debug.c +1
-3@@ -168,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level =ODM_DBG_TRACE ; dm->fw_debug_components =0 ; - dm->debug_components = - -0 ; + dm->debug_components =0 ;Does this belong here? I don't see an if nearby. You should make a series if you want to do two different things on the same file.
Quoted 4 lines
Quoted 1 line
julia
Thank you, Julia, for reviewing my submission! I will separate different types of fixes into their own patches and resend these.
Hi Maya,
I'm guessing that while you were working on your original plan to remove unnecessary conditions you saw the weird looking piece of code above and decided to fix it as well. As a result, while you dealt nicely with this cleanup, you ended up with unrelated changes in the same patch.
An easy way to work around it is the '-p' flag to 'git add'. This flag lets you interactively select hunks to stage in git; you don't have to 'git add' and entire file, but can just add parts of it.
Quoted 7 lines
This way, you stage only the relevant hunks and 'git commit' them when you're ready. Rinse and repeat for every set of hunks that represents a single logical change.
--
Thanks,
Sasha
Thank you for teaching me, Sasha!
You read my mind :-) I included changes that I had not targeted because I found one and Julia told me about the other, and I thought that it would be clear if I wrote about them as part of the commit message. Sorry, lazy me.
I have never used that special flag. That is fantastic!
I will keep in mind: only a single logical type of change in a patch.
Maya