All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Briana Oursler <briana.oursler@gmail.com>
Cc: gregkh@linuxfoundation.org, forest@alittletooquiet.net,
	julia.lawall@inria.fr, outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH 3/4] Staging: vt6655: Create new variable len.
Date: Mon, 30 Mar 2020 20:03:56 +0200	[thread overview]
Message-ID: <20200330200356.6e50ab08@elisabeth> (raw)
In-Reply-To: <8e046065ad86e79b8133f6c24ecf055c3b5a897f.1585542564.git.briana.oursler@gmail.com>

On Sun, 29 Mar 2020 21:48:01 -0700
Briana Oursler <briana.oursler@gmail.com> wrote:

> Create variable len to determine function input needed for
> s_uGetTxRsvTime. Use len to eliminate a nested if else statement, reduce
> code duplication, and shorten long lines found by checkpatch.

The commit description looks okayish to me, except perhaps that the
solution (creating a new variable) shouldn't be stated first. The
commit title is not very representative of the change, though.

> 
> Signed-off-by: Briana Oursler <briana.oursler@gmail.com>
> ---
>  drivers/staging/vt6655/rxtx.c | 44 +++++++++++++----------------------
>  1 file changed, 16 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
> index 4be867b95d9d..6068cf65e3fe 100644
> --- a/drivers/staging/vt6655/rxtx.c
> +++ b/drivers/staging/vt6655/rxtx.c
> @@ -240,10 +240,16 @@ s_uGetDataDuration(
>  {
>  	bool bLastFrag = false;
>  	unsigned int uAckTime = 0, uNextPktTime = 0;
> +	unsigned int len;

The other two are declared on one line, you could add it there.

>  
>  	if (uFragIdx == (uMACfragNum - 1))
>  		bLastFrag = true;
>  
> +	if (uFragIdx == (uMACfragNum - 2))
> +		len = cbLastFragmentSize;
> +	else
> +		len = cbFrameLength;
> +
>  	switch (byDurType) {
>  	case DATADUR_B:    /* DATADUR_B */
>  		if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */
> @@ -254,10 +260,7 @@ s_uGetDataDuration(
>  				return 0;
>  			}
>  		} else {/* First Frag or Mid Frag */
> -			if (uFragIdx == (uMACfragNum - 2))
> -				uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
> -			else
> -				uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
> +			uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wRate, bNeedAck);
>  
>  			if (bNeedAck) {
>  				uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
> @@ -278,10 +281,7 @@ s_uGetDataDuration(
>  				return 0;
>  			}
>  		} else {/* First Frag or Mid Frag */
> -			if (uFragIdx == (uMACfragNum - 2))
> -				uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
> -			else
> -				uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
> +			uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, len, wRate, bNeedAck);
>  
>  			if (bNeedAck) {
>  				uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
> @@ -308,16 +308,9 @@ s_uGetDataDuration(
>  				wRate = RATE_54M;
>  
>  			if (byFBOption == AUTO_FB_0) {
> -				if (uFragIdx == (uMACfragNum - 2))
> -					uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
> -				else
> -					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);
> +				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) {
> @@ -338,17 +331,11 @@ s_uGetDataDuration(
>  				return 0;
>  			}
>  		} else { /* First Frag or Mid Frag */
> +

Unrelated change.

>  			if (byFBOption == AUTO_FB_0) {
> -				if (uFragIdx == (uMACfragNum - 2))
> -					uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
> -				else
> -					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);
> +				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) {
> @@ -356,6 +343,7 @@ s_uGetDataDuration(
>  			} else {
>  				uAckTime = 0;
>  			}
> +

Unrelated change.

>  			return pDevice->uSIFS + uAckTime + uNextPktTime;
>  		}
>  		break;

-- 
Stefano



  reply	other threads:[~2020-03-30 18:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  4:47 [PATCH 0/4] staging: vt6655: Simplify statement logic Briana Oursler
2020-03-30  4:47 ` [PATCH 1/4] Staging: vt6655: Limit return statements Briana Oursler
2020-03-30 18:01   ` [Outreachy kernel] " Stefano Brivio
2020-03-30  4:48 ` [PATCH 2/4] Staging: vt6655: Raise rate determination logic Briana Oursler
2020-03-30 18:02   ` [Outreachy kernel] " Stefano Brivio
2020-03-30  4:48 ` [PATCH 3/4] Staging: vt6655: Create new variable len Briana Oursler
2020-03-30 18:03   ` Stefano Brivio [this message]
2020-03-30  4:48 ` [PATCH 4/4] Staging: vt6655: Format spaces Briana Oursler
2020-03-30 18:02   ` [Outreachy kernel] " Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200330200356.6e50ab08@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=briana.oursler@gmail.com \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=julia.lawall@inria.fr \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.