Cleaning s_uGetDataDuration function
cover Cleaning s_uGetDataDuration function
This patch set will eliminate few checkpatch LONG_LINE errors. Simplify code paths by:
- returning at the end of case body
- removing unnecessary else branches
Matej Dujava (5):
staging: vt6655: merge two switch cases in s_uGetDataDuration
staging: vt6655: do calculation of uAckTime first
staging: vt6655: remove else after return and invert condition
staging: vt6655: return at the ond of case body
staging: vt6655: extract index manupulation out of function call
drivers/staging/vt6655/rxtx.c | 140 ++++++++++++---------------------- 1 file changed, 48 insertions(+), 92 deletions(-)
--
2.26.2
PATCH 1/5 staging: vt6655: merge two switch cases in s_uGetDataDuration
This patch will reuse code for two cases.
--- drivers/staging/vt6655/rxtx.c | 34 ---------------------------------- 1 file changed, 34 deletions(-)
drivers/staging/vt6655/rxtx.c +0 -34
@@ -296,40 +296,6 @@ s_uGetDataDuration(break ;case DATADUR_A_F0 :/* DATADUR_A_F0 */ -if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ -if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, byPktType,14 , pDevice->byTopOFDMBasicRate); -return pDevice->uSIFS + uAckTime; - }else { -return 0 ; - } - }else {/* First Frag or Mid Frag */ -if (wRate <RATE_18M ) - wRate =RATE_18M ; -else if (wRate >RATE_54M ) - wRate =RATE_54M ; - -if (byFBOption ==AUTO_FB_0 ) { - uNextPktTime =s_uGetTxRsvTime (pDevice, - byPktType, len, - wFB_Opt0[FB_RATE0 ][wRate -RATE_18M ], - bNeedAck); - }else { - uNextPktTime =s_uGetTxRsvTime (pDevice, - byPktType, len, - wFB_Opt1[FB_RATE0 ][wRate -RATE_18M ], - bNeedAck); - } - -if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, - byPktType,14 , - pDevice->byTopOFDMBasicRate); - } -return pDevice->uSIFS + uAckTime + uNextPktTime; - } -break ; -case DATADUR_A_F1 :/* DATADUR_A_F1 */ if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ if (bNeedAck) {
Signature · 1 line
2.26.2
PATCH 2/5 staging: vt6655: do calculation of uAckTime first
In reply to Matej DujavaThis patch is extracting calculation of uAckTime in one place, at the start of case body.
--- drivers/staging/vt6655/rxtx.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/staging/vt6655/rxtx.c +15 -18
@@ -255,9 +255,13 @@ s_uGetDataDuration(switch (byDurType) {case DATADUR_B :/* DATADUR_B */ +if (bNeedAck) { + uAckTime =bb_get_frame_time (pDevice->byPreambleType, + byPktType,14 , + pDevice->byTopCCKBasicRate); + }if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, byPktType,14 , pDevice->byTopCCKBasicRate);return pDevice->uSIFS + uAckTime; }else {return 0 ;
@@ -265,19 +269,18 @@ s_uGetDataDuration( }else {/* First Frag or Mid Frag */ uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck); -if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, - byPktType,14 , - pDevice->byTopCCKBasicRate); - }return pDevice->uSIFS + uAckTime + uNextPktTime; }break ;case DATADUR_A :/* DATADUR_A */ +if (bNeedAck) { + uAckTime =bb_get_frame_time (pDevice->byPreambleType, + byPktType,14 , + pDevice->byTopOFDMBasicRate); + }if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, byPktType,14 , pDevice->byTopOFDMBasicRate);return pDevice->uSIFS + uAckTime; }else {return 0 ;
@@ -286,20 +289,19 @@ s_uGetDataDuration( uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck); -if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, - byPktType,14 , - pDevice->byTopOFDMBasicRate); - }return pDevice->uSIFS + uAckTime + uNextPktTime; }break ;case DATADUR_A_F0 :/* DATADUR_A_F0 */ case DATADUR_A_F1 :/* DATADUR_A_F1 */ +if (bNeedAck) { + uAckTime =bb_get_frame_time (pDevice->byPreambleType, + byPktType,14 , + pDevice->byTopOFDMBasicRate); + }if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, byPktType,14 , pDevice->byTopOFDMBasicRate);return pDevice->uSIFS + uAckTime; }else {return 0 ;
@@ -322,11 +324,6 @@ s_uGetDataDuration( bNeedAck); } -if (bNeedAck) { - uAckTime =bb_get_frame_time (pDevice->byPreambleType, - byPktType,14 , - pDevice->byTopOFDMBasicRate); - }return pDevice->uSIFS + uAckTime + uNextPktTime; }break ;
Signature · 1 line
2.26.2
PATCH 3/5 staging: vt6655: remove else after return and invert condition
In reply to Matej DujavaThis patch will prepare us to make return at the end of case body
--- drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/vt6655/rxtx.c +18 -18
@@ -260,13 +260,13 @@ s_uGetDataDuration( byPktType,14 , pDevice->byTopCCKBasicRate); } -if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ -if (bNeedAck) { -return pDevice->uSIFS + uAckTime; - }else { +/* Non Frag or Last Frag */ +if ((uMACfragNum ==1 ) || bLastFrag) { +if (!bNeedAck)return 0 ; - } - }else {/* First Frag or Mid Frag */ +return pDevice->uSIFS + uAckTime; + }else { +/* First Frag or Mid Frag */ uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck);return pDevice->uSIFS + uAckTime + uNextPktTime;
@@ -279,13 +279,13 @@ s_uGetDataDuration( byPktType,14 , pDevice->byTopOFDMBasicRate); } -if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ -if (bNeedAck) { -return pDevice->uSIFS + uAckTime; - }else { +/* Non Frag or Last Frag */ +if ((uMACfragNum ==1 ) || bLastFrag) { +if (!bNeedAck)return 0 ; - } - }else {/* First Frag or Mid Frag */ +return pDevice->uSIFS + uAckTime; + }else { +/* First Frag or Mid Frag */ uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck);
@@ -300,13 +300,13 @@ s_uGetDataDuration( byPktType,14 , pDevice->byTopOFDMBasicRate); } -if (((uMACfragNum ==1 )) || bLastFrag) {/* Non Frag or Last Frag */ -if (bNeedAck) { -return pDevice->uSIFS + uAckTime; - }else { +/* Non Frag or Last Frag */ +if ((uMACfragNum ==1 ) || bLastFrag) { +if (!bNeedAck)return 0 ; - } - }else {/* First Frag or Mid Frag */ +return pDevice->uSIFS + uAckTime; + }else { +/* First Frag or Mid Frag */ if (wRate <RATE_18M ) wRate =RATE_18M ;else if (wRate >RATE_54M )
Signature · 1 line
2.26.2
PATCH 4/5 staging: vt6655: return at the ond of case body
In reply to Matej DujavaThis patch will unify exit point for s_uGetDataDuration function.
--- drivers/staging/vt6655/rxtx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/staging/vt6655/rxtx.c +6 -12
@@ -264,14 +264,12 @@ s_uGetDataDuration(if ((uMACfragNum ==1 ) || bLastFrag) {if (!bNeedAck)return 0 ; -return pDevice->uSIFS + uAckTime; }else {/* First Frag or Mid Frag */ uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck); - -return pDevice->uSIFS + uAckTime + uNextPktTime; } -break ; + +return pDevice->uSIFS + uAckTime + uNextPktTime;case DATADUR_A :/* DATADUR_A */ if (bNeedAck) {
@@ -283,15 +281,13 @@ s_uGetDataDuration(if ((uMACfragNum ==1 ) || bLastFrag) {if (!bNeedAck)return 0 ; -return pDevice->uSIFS + uAckTime; }else {/* First Frag or Mid Frag */ uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck); - -return pDevice->uSIFS + uAckTime + uNextPktTime; } -break ; + +return pDevice->uSIFS + uAckTime + uNextPktTime;case DATADUR_A_F0 :/* DATADUR_A_F0 */ case DATADUR_A_F1 :/* DATADUR_A_F1 */
@@ -304,7 +300,6 @@ s_uGetDataDuration(if ((uMACfragNum ==1 ) || bLastFrag) {if (!bNeedAck)return 0 ; -return pDevice->uSIFS + uAckTime; }else {/* First Frag or Mid Frag */ if (wRate <RATE_18M )
@@ -323,10 +318,9 @@ s_uGetDataDuration( wFB_Opt1[FB_RATE0 ][wRate -RATE_18M ], bNeedAck); } - -return pDevice->uSIFS + uAckTime + uNextPktTime; } -break ; + +return pDevice->uSIFS + uAckTime + uNextPktTime;default :break ;
Signature · 1 line
2.26.2
PATCH 5/5 staging: vt6655: extract index manupulation out of function call
In reply to Matej DujavaThis patch will remove if/else by selecting proper argument before function call, also index is updated before function call.
--- drivers/staging/vt6655/rxtx.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/staging/vt6655/rxtx.c +13 -14
@@ -266,7 +266,8 @@ s_uGetDataDuration(return 0 ; }else {/* First Frag or Mid Frag */ - uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, wRate, bNeedAck); + uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, + len, wRate, bNeedAck); }return pDevice->uSIFS + uAckTime + uNextPktTime;
@@ -283,8 +284,8 @@ s_uGetDataDuration(return 0 ; }else {/* First Frag or Mid Frag */ - uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, len, - wRate, bNeedAck); + uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, + len, wRate, bNeedAck); }return pDevice->uSIFS + uAckTime + uNextPktTime;
@@ -307,17 +308,15 @@ s_uGetDataDuration(else if (wRate >RATE_54M ) wRate =RATE_54M ; -if (byFBOption ==AUTO_FB_0 ) { - uNextPktTime =s_uGetTxRsvTime (pDevice, - byPktType, len, - wFB_Opt0[FB_RATE0 ][wRate -RATE_18M ], - bNeedAck); - }else { - uNextPktTime =s_uGetTxRsvTime (pDevice, - byPktType, len, - wFB_Opt1[FB_RATE0 ][wRate -RATE_18M ], - bNeedAck); - } + wRate -=RATE_18M ; + +if (byFBOption ==AUTO_FB_0 ) + wRate = wFB_Opt0[FB_RATE0 ][wRate]; +else + wRate = wFB_Opt1[FB_RATE0 ][wRate]; + + uNextPktTime =s_uGetTxRsvTime (pDevice, byPktType, + len, wRate, bNeedAck); }return pDevice->uSIFS + uAckTime + uNextPktTime;
Signature · 1 line
2.26.2