linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: vt6655: return early if not bNeedAck
@ 2020-05-02 22:16 Matej Dujava
  2020-05-02 22:16 ` [PATCH 2/2] staging: vt6655: fix LONG_LINE warning Matej Dujava
  0 siblings, 1 reply; 4+ messages in thread
From: Matej Dujava @ 2020-05-02 22:16 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 check for bNeedAck before making bb_get_frame_time call, so
in case we dont need uAckTime, we can return early.

Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
 drivers/staging/vt6655/rxtx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 2f9c2ead3cb8..dda578436e64 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -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,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] staging: vt6655: fix LONG_LINE warning
  2020-05-02 22:16 [PATCH 1/2] staging: vt6655: return early if not bNeedAck Matej Dujava
@ 2020-05-02 22:16 ` Matej Dujava
  2020-05-03  5:11   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Matej Dujava @ 2020-05-02 22:16 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 fix LONG_LINE error from checkpatch, by createing temporary
variable so call to the function is not in if/else block.

Signed-off-by: Matej Dujava <mdujava@kocurkovo.cz>
---
 drivers/staging/vt6655/rxtx.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index dda578436e64..782177dfd67e 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -164,16 +164,24 @@ s_uGetTxRsvTime(
 )
 {
 	unsigned int uDataTime, uAckTime;
+	unsigned short basic_rate;
 
 	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);
+	/*
+	 * CCK mode  - 11b
+	 * OFDM mode - 11g 2.4G & 11a 5G
+	 */
+	if (byPktType == PK_TYPE_11B)
+		basic_rate = (unsigned short)pDevice->byTopCCKBasicRate;
+	else
+		basic_rate = (unsigned short)pDevice->byTopOFDMBasicRate;
+
+	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
+				     basic_rate);
 
 	return uDataTime + pDevice->uSIFS + uAckTime;
 }
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging: vt6655: fix LONG_LINE warning
  2020-05-02 22:16 ` [PATCH 2/2] staging: vt6655: fix LONG_LINE warning Matej Dujava
@ 2020-05-03  5:11   ` Joe Perches
  2020-05-03  9:15     ` Matej Dujava
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2020-05-03  5:11 UTC (permalink / raw)
  To: Matej Dujava, Forest Bond, Greg Kroah-Hartman, devel, linux-kernel
  Cc: Stefano Brivio, Briana Oursler, Frank A. Cancio Bello

On Sun, 2020-05-03 at 00:16 +0200, Matej Dujava wrote:
> This patch will fix LONG_LINE error from checkpatch, by createing temporary
> variable so call to the function is not in if/else block.
[]
> diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
[]
> @@ -164,16 +164,24 @@ s_uGetTxRsvTime(
>  )
>  {
>  	unsigned int uDataTime, uAckTime;
> +	unsigned short basic_rate;
>  
>  	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);
> +	/*
> +	 * CCK mode  - 11b
> +	 * OFDM mode - 11g 2.4G & 11a 5G
> +	 */
> +	if (byPktType == PK_TYPE_11B)
> +		basic_rate = (unsigned short)pDevice->byTopCCKBasicRate;
> +	else
> +		basic_rate = (unsigned short)pDevice->byTopOFDMBasicRate;
> +
> +	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
> +				     basic_rate);
>  
>  	return uDataTime + pDevice->uSIFS + uAckTime;
>  }

perhaps simpler using a ?:

	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
				     byPktType == PK_TYPE_11B
				     ? pDevice->byTopCCKBasicRate
				     : pDevice->byTopOFDMBasicRate);

the casts aren't necessary either as both by... fields are u8



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] staging: vt6655: fix LONG_LINE warning
  2020-05-03  5:11   ` Joe Perches
@ 2020-05-03  9:15     ` Matej Dujava
  0 siblings, 0 replies; 4+ messages in thread
From: Matej Dujava @ 2020-05-03  9:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: Forest Bond, Greg Kroah-Hartman, devel, linux-kernel,
	Stefano Brivio, Briana Oursler, Frank A. Cancio Bello

On Sat, May 02, 2020 at 10:11:43PM -0700, Joe Perches wrote:
>On Sun, 2020-05-03 at 00:16 +0200, Matej Dujava wrote:
>> This patch will fix LONG_LINE error from checkpatch, by createing temporary
>> variable so call to the function is not in if/else block.
>[]
>> diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
>[]

Sorry, am I missing something here?

>> @@ -164,16 +164,24 @@ s_uGetTxRsvTime(
>>  )
>>  {
>>  	unsigned int uDataTime, uAckTime;
>> +	unsigned short basic_rate;
>>
>>  	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);
>> +	/*
>> +	 * CCK mode  - 11b
>> +	 * OFDM mode - 11g 2.4G & 11a 5G
>> +	 */
>> +	if (byPktType == PK_TYPE_11B)
>> +		basic_rate = (unsigned short)pDevice->byTopCCKBasicRate;
>> +	else
>> +		basic_rate = (unsigned short)pDevice->byTopOFDMBasicRate;
>> +
>> +	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
>> +				     basic_rate);
>>
>>  	return uDataTime + pDevice->uSIFS + uAckTime;
>>  }
>
>perhaps simpler using a ?:
>
>	uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14,
>				     byPktType == PK_TYPE_11B
>				     ? pDevice->byTopCCKBasicRate
>				     : pDevice->byTopOFDMBasicRate);
>
>the casts aren't necessary either as both by... fields are u8

Thank you, will resend my patch.

>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-03  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 22:16 [PATCH 1/2] staging: vt6655: return early if not bNeedAck Matej Dujava
2020-05-02 22:16 ` [PATCH 2/2] staging: vt6655: fix LONG_LINE warning Matej Dujava
2020-05-03  5:11   ` Joe Perches
2020-05-03  9:15     ` 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).