Skip to contentSkip to conversation

Early return in s_uGetTxRsvTime

PATCH New Matej Dujava 1 participant 3 messages May 3, 2020 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover Early return in s_uGetTxRsvTime

This patch set will fix checkpatch LONG_LINE warnings and will save us one call of bb_get_frame_time in case od !bNeedAck.

Change history:
v2: Implemented advice of ternary operator from Joe Perches <[email protected]>

Matej Dujava (2):
staging: vt6655: return early if not bNeedAck
staging: vt6655: fix LONG_LINE warning

 drivers/staging/vt6655/rxtx.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

--
2.26.2

#1 lore raw

PATCH v2 1/2 staging: vt6655: return early if not bNeedAck

This patch will check for bNeedAck before making bb_get_frame_time call, so in case we dont need uAckTime, we can return early.

---
 drivers/staging/vt6655/rxtx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/vt6655/rxtx.c +5 -4
index 2f9c2ead3cb8..dda578436e64 100644
@@ -166,15 +166,16 @@ s_uGetTxRsvTime(
 	unsigned int uDataTime, uAckTime;
 
 	uDataTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, cbFrameLength, wRate);
+
+	if (!bNeedAck)
+		return uDataTime;
+
 	if (byPktType == PK_TYPE_11B) /* llb,CCK mode */
 		uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate);
 	else /* 11g 2.4G OFDM mode & 11a 5G OFDM mode */
 		uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate);
 
-	if (bNeedAck)
-		return uDataTime + pDevice->uSIFS + uAckTime;
-	else
-		return uDataTime;
+	return uDataTime + pDevice->uSIFS + uAckTime;
 }
 
 static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/2 staging: vt6655: fix LONG_LINE warning

In reply to Matej Dujava

This patch will fix LONG_LINE error from checkpatch, by using ternary operator.

---
 drivers/staging/vt6655/rxtx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/staging/vt6655/rxtx.c +8 -4
index dda578436e64..994c19f1de43 100644
@@ -170,10 +170,14 @@ s_uGetTxRsvTime(
 	if (!bNeedAck)
 		return uDataTime;
 
-	if (byPktType == PK_TYPE_11B) /* llb,CCK mode */
-		uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate);
-	else /* 11g 2.4G OFDM mode & 11a 5G OFDM mode */
-		uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate);
+	/*
+	 * CCK mode  - 11b
+	 * OFDM mode - 11g 2.4G & 11a 5G
+	 */
+	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
+				     byPktType == PK_TYPE_11B ?
+				     pDevice->byTopCCKBasicRate :
+				     pDevice->byTopOFDMBasicRate);
 
 	return uDataTime + pDevice->uSIFS + uAckTime;
 }
Signature · 1 line
2.26.2