2020-05-02 22:18:47

by Matej Dujava

[permalink] [raw]
Subject: [PATCH 2/2] staging: vt6655: fix LONG_LINE warning

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 <[email protected]>
---
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


2020-05-03 05:16:07

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 2/2] staging: vt6655: fix LONG_LINE warning

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


2020-05-03 09:19:33

by Matej Dujava

[permalink] [raw]
Subject: Re: [PATCH 2/2] staging: vt6655: fix LONG_LINE warning

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.

>
>