Staging: vt6655: Eliminate nested if else

Eliminate  nested if else statement, reduce code duplication, and
shorten long lines by creating a new variable, len, to determine
function input needed for s_uGetTxRsvTime.

Signed-off-by: Briana Oursler <briana.oursler@gmail.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Link: https://lore.kernel.org/r/301ff66e13e76be6416b5c0f8359249fa25f08e3.1585763457.git.briana.oursler@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Briana Oursler 2020-04-01 11:03:41 -07:00 committed by Greg Kroah-Hartman
parent e781fd1b33
commit b03ee7b2b8
1 changed files with 14 additions and 29 deletions

View File

@ -243,11 +243,16 @@ s_uGetDataDuration(
) )
{ {
bool bLastFrag = false; bool bLastFrag = false;
unsigned int uAckTime = 0, uNextPktTime = 0; unsigned int uAckTime = 0, uNextPktTime = 0, len;
if (uFragIdx == (uMACfragNum - 1)) if (uFragIdx == (uMACfragNum - 1))
bLastFrag = true; bLastFrag = true;
if (uFragIdx == (uMACfragNum - 2))
len = cbLastFragmentSize;
else
len = cbFrameLength;
switch (byDurType) { switch (byDurType) {
case DATADUR_B: /* DATADUR_B */ case DATADUR_B: /* DATADUR_B */
if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */ if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */
@ -258,10 +263,7 @@ s_uGetDataDuration(
return 0; return 0;
} }
} else {/* First Frag or Mid Frag */ } else {/* First Frag or Mid Frag */
if (uFragIdx == (uMACfragNum - 2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wRate, bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
else
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
if (bNeedAck) if (bNeedAck)
uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
@ -278,10 +280,7 @@ s_uGetDataDuration(
return 0; return 0;
} }
} else {/* First Frag or Mid Frag */ } else {/* First Frag or Mid Frag */
if (uFragIdx == (uMACfragNum - 2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wRate, bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
else
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
if (bNeedAck) if (bNeedAck)
uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
@ -304,16 +303,9 @@ s_uGetDataDuration(
wRate = RATE_54M; wRate = RATE_54M;
if (byFBOption == AUTO_FB_0) { if (byFBOption == AUTO_FB_0) {
if (uFragIdx == (uMACfragNum - 2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); } else {
else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
} else { /* (byFBOption == AUTO_FB_1) */
if (uFragIdx == (uMACfragNum - 2))
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
else
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
} }
if (bNeedAck) if (bNeedAck)
@ -337,16 +329,9 @@ s_uGetDataDuration(
wRate = RATE_54M; wRate = RATE_54M;
if (byFBOption == AUTO_FB_0) { if (byFBOption == AUTO_FB_0) {
if (uFragIdx == (uMACfragNum - 2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); } else {
else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck);
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
} else { /* (byFBOption == AUTO_FB_1) */
if (uFragIdx == (uMACfragNum - 2))
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
else
uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck);
} }
if (bNeedAck) if (bNeedAck)