Staging: rtl8188eu: Cleanup code to increase readability
PATCH 1/1 Staging: rtl8188eu: Cleanup code to increase readability
Code cleanup includes removing unneeded variables and replacing ternary operators with existing macro to increase readability and make it more compact.
--- drivers/staging/rtl8188eu/hal/phy.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-)
drivers/staging/rtl8188eu/hal/phy.c +11 -24
@@ -1024,47 +1024,34 @@ static void pi_mode_switch(struct adapter *adapt, bool pi_mode)static bool simularity_compare (struct adapter *adapt,s32 resulta[][8 ],u8 c1,u8 c2) { -u32 i, j, diff, sim_bitmap, bound =0 ; +u32 i, j, diff, sim_bitmap =0 , bound;struct hal_data_8188e *hal_data =GET_HAL_DATA (adapt);struct odm_dm_struct *dm_odm = &hal_data->odmpriv;u8 final_candidate[2 ] = {0xFF ,0xFF };/* for path A and path B */ bool result = true; -bool is2t; -s32 tmp1 =0 , tmp2 =0 ; +s32 tmp1, tmp2;if ((dm_odm->RFType ==ODM_2T2R ) || (dm_odm->RFType ==ODM_2T3R ) || - (dm_odm->RFType ==ODM_2T4R )) - is2t = true; -else - is2t = false; - -if (is2t) + (dm_odm->RFType ==ODM_2T4R )) { bound =8 ; -else + }else { bound =4 ; - - sim_bitmap =0 ; + }for (i =0 ; i < bound; i++) { -if ((i ==1 ) || (i ==3 ) || (i ==5 ) || (i ==7 )) { + tmp1 = resulta[c1][i]; + tmp2 = resulta[c2][i]; + +if (i%2 ) {if ((resulta[c1][i] &0x00000200 ) !=0 ) tmp1 = resulta[c1][i] |0xFFFFFC00 ; -else - tmp1 = resulta[c1][i]; -if ((resulta[c2][i] &0x00000200 ) !=0 ) tmp2 = resulta[c2][i] |0xFFFFFC00 ; -else - tmp2 = resulta[c2][i]; - }else { - tmp1 = resulta[c1][i]; - tmp2 = resulta[c2][i]; } - diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); - + diff =abs (tmp1 - tmp2);if (diff >MAX_TOLERANCE ) { -if ((i ==2 || i ==6 ) && !sim_bitmap) { +if (i ==2 || i ==6 ) {if (resulta[c1][i] + resulta[c1][i+1 ] ==0 ) final_candidate[(i/4 )] = c2;else if (resulta[c2][i] + resulta[c2][i+1 ] ==0 )
Signature · 1 line
1.9.1
Quoted 28 lines · Vatika Harlalka
Code cleanup includes removing unneeded variables and replacing ternary operators with existing macro to increase readability and make it more compact.
Signed-off-by Vatika Harlalka <[email protected]>--- drivers/staging/rtl8188eu/hal/phy.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-)drivers/staging/rtl8188eu/hal/phy.c +2
-3@@ -1024,47 +1024,34 @@ static void pi_mode_switch(struct adapter *adapt, bool pi_mode)static bool simularity_compare (struct adapter *adapt,s32 resulta[][8 ],u8 c1,u8 c2) { -u32 i, j, diff, sim_bitmap, bound =0 ; +u32 i, j, diff, sim_bitmap =0 , bound;struct hal_data_8188e *hal_data =GET_HAL_DATA (adapt);struct odm_dm_struct *dm_odm = &hal_data->odmpriv;u8 final_candidate[2 ] = {0xFF ,0xFF };/* for path A and path B */ bool result = true; -bool is2t; -s32 tmp1 =0 , tmp2 =0 ; +s32 tmp1, tmp2; if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) ||
drivers/staging/rtl8188eu/hal/phy.c static void pi_mode_switch(struct adapter *adapt, bool pi_mode) · line 1037
Quoted 10 lines
drivers/staging/rtl8188eu/hal/phy.c +2
-7- (dm_odm->RFType == ODM_2T4R)) - is2t = true; - else - is2t = false; - -if (is2t) + (dm_odm->RFType == ODM_2T4R)) { bound = 8; -else + } else{
Missing space before {
The changes seem to follow different reasoning. It may be better to break them up, so that you can explain the reasoning in each case.
julia
Quoted 44 lines
drivers/staging/rtl8188eu/hal/phy.c +7
-15bound =4 ; - - sim_bitmap =0 ; + }for (i =0 ; i < bound; i++) { -if ((i ==1 ) || (i ==3 ) || (i ==5 ) || (i ==7 )) { + tmp1 = resulta[c1][i]; + tmp2 = resulta[c2][i]; + +if (i%2 ) {if ((resulta[c1][i] &0x00000200 ) !=0 ) tmp1 = resulta[c1][i] |0xFFFFFC00 ; -else - tmp1 = resulta[c1][i]; -if ((resulta[c2][i] &0x00000200 ) !=0 ) tmp2 = resulta[c2][i] |0xFFFFFC00 ; -else - tmp2 = resulta[c2][i]; - }else { - tmp1 = resulta[c1][i]; - tmp2 = resulta[c2][i]; } - diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); - + diff =abs (tmp1 - tmp2);if (diff >MAX_TOLERANCE ) { -if ((i ==2 || i ==6 ) && !sim_bitmap) { +if (i ==2 || i ==6 ) {if (resulta[c1][i] + resulta[c1][i+1 ] ==0 ) final_candidate[(i/4 )] = c2;else if (resulta[c2][i] + resulta[c2][i+1 ] ==0 ) --1.9.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/20150227125330.GA15425%40gmail.com.
For more options, visit https://groups.google.com/d/optout.