* [PATCH 0/5] Cleaning s_uGetDataDuration function
@ 2020-05-03 13:29 Matej Dujava
2020-05-03 13:29 ` [PATCH 1/5] staging: vt6655: merge two switch cases in s_uGetDataDuration Matej Dujava
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] staging: vt6655: merge two switch cases in s_uGetDataDuration
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
@ 2020-05-03 13:29 ` Matej Dujava
2020-05-03 13:29 ` [PATCH 2/5] staging: vt6655: do calculation of uAckTime first Matej Dujava
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
This patch will reuse code for two cases.
Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
drivers/staging/vt6655/rxtx.c | 34 ----------------------------------
1 file changed, 34 deletions(-)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 2f9c2ead3cb8..28f0cda36dec 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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) {
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] staging: vt6655: do calculation of uAckTime first
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
2020-05-03 13:29 ` [PATCH 1/5] staging: vt6655: merge two switch cases in s_uGetDataDuration Matej Dujava
@ 2020-05-03 13:29 ` Matej Dujava
2020-05-03 13:29 ` [PATCH 3/5] staging: vt6655: remove else after return and invert condition Matej Dujava
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
This patch is extracting calculation of uAckTime in one place, at the
start of case body.
Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
drivers/staging/vt6655/rxtx.c | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 28f0cda36dec..01ceace253a4 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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;
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] staging: vt6655: remove else after return and invert condition
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
2020-05-03 13:29 ` [PATCH 1/5] staging: vt6655: merge two switch cases in s_uGetDataDuration Matej Dujava
2020-05-03 13:29 ` [PATCH 2/5] staging: vt6655: do calculation of uAckTime first Matej Dujava
@ 2020-05-03 13:29 ` Matej Dujava
2020-05-03 13:29 ` [PATCH 4/5] staging: vt6655: return at the ond of case body Matej Dujava
2020-05-03 13:29 ` [PATCH 5/5] staging: vt6655: extract index manupulation out of function call Matej Dujava
4 siblings, 0 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
This patch will prepare us to make return at the end of case body
Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
drivers/staging/vt6655/rxtx.c | 36 +++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 01ceace253a4..61f7077bb75f 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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)
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] staging: vt6655: return at the ond of case body
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
` (2 preceding siblings ...)
2020-05-03 13:29 ` [PATCH 3/5] staging: vt6655: remove else after return and invert condition Matej Dujava
@ 2020-05-03 13:29 ` Matej Dujava
2020-05-03 13:29 ` [PATCH 5/5] staging: vt6655: extract index manupulation out of function call Matej Dujava
4 siblings, 0 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
This patch will unify exit point for s_uGetDataDuration function.
Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
drivers/staging/vt6655/rxtx.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 61f7077bb75f..c4d62c27f1c1 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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;
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] staging: vt6655: extract index manupulation out of function call
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
` (3 preceding siblings ...)
2020-05-03 13:29 ` [PATCH 4/5] staging: vt6655: return at the ond of case body Matej Dujava
@ 2020-05-03 13:29 ` Matej Dujava
4 siblings, 0 replies; 6+ messages in thread
From: Matej Dujava @ 2020-05-03 13:29 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello, Matej Dujava
This patch will remove if/else by selecting proper argument before
function call, also index is updated before function call.
Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
drivers/staging/vt6655/rxtx.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index c4d62c27f1c1..1e025bb72810 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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;
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-05-03 13:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 13:29 [PATCH 0/5] Cleaning s_uGetDataDuration function Matej Dujava
2020-05-03 13:29 ` [PATCH 1/5] staging: vt6655: merge two switch cases in s_uGetDataDuration Matej Dujava
2020-05-03 13:29 ` [PATCH 2/5] staging: vt6655: do calculation of uAckTime first Matej Dujava
2020-05-03 13:29 ` [PATCH 3/5] staging: vt6655: remove else after return and invert condition Matej Dujava
2020-05-03 13:29 ` [PATCH 4/5] staging: vt6655: return at the ond of case body Matej Dujava
2020-05-03 13:29 ` [PATCH 5/5] staging: vt6655: extract index manupulation out of function call Matej Dujava
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).