public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Cc: outreachy@lists.linux.dev, julia.lawall@inria.fr,
	gregkh@linuxfoundation.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, hdegoede@redhat.com,
	mchehab@kernel.org, sakari.ailus@linux.intel.com
Subject: Re: [PATCH v2 3/3] staging: rtl8723bs: Prevent duplicate NULL tests on a value
Date: Thu, 3 Apr 2025 16:39:33 +0300	[thread overview]
Message-ID: <Z-6PlWGmn09hYYKU@smile.fi.intel.com> (raw)
In-Reply-To: <1325d06f5a4eb18eb52eb20d5af89207504c46b6.1743685415.git.abrahamadekunle50@gmail.com>

On Thu, Apr 03, 2025 at 02:26:43PM +0100, Abraham Samuel Adekunle wrote:
> When a value has been tested for NULL in an expression, a
> second NULL test on the same value in another expression
> is unnecessary when the value has not been assigned NULL.
> 
> Remove unnecessary duplicate NULL tests on the same value that
> has previously been NULL tested.
> 
> Found by Coccinelle

Missing period.

...

> +			psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
> +			psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
> +			pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
> +
> +			SetSeqNum(hdr, pattrib->seqnum);
> +
> +			/* check if enable ampdu */
> +			if (pattrib->ht_en && psta->htpriv.ampdu_enable)
> +				if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority))
> +					pattrib->ampdu_en = true;
> +
> +			/* re-check if enable ampdu by BA_starting_seqctrl */
> +			if (pattrib->ampdu_en == true) {
> +				u16 tx_seq;
> +
> +				tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f];
> +
> +				/* check BA_starting_seqctrl */
> +				if (SN_LESS(pattrib->seqnum, tx_seq)) {
> +					pattrib->ampdu_en = false;/* AGG BK */
> +				} else if (SN_EQUAL(pattrib->seqnum, tx_seq)) {

> +					psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff;

While at it, make this more readable:

					psta->BA_starting_seqctrl[pattrib->priority & 0x0f] =
						(tx_seq + 1) & 0xfff;


> +					pattrib->ampdu_en = true;/* AGG EN */
> +				} else {

> +					psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff;

Ditto.

Also consider to use module operator as it shows the exact amount of the
records we support in the circular buffer.

					psta->BA_starting_seqctrl[pattrib->priority & 0x0f] =
						(pattrib->seqnum + 1) % 4096;

Since it's power-of-two denominator, it will be optimised by the compiler to
the same code as it's now.

> +					pattrib->ampdu_en = true;/* AGG EN */
>  				}

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-04-03 13:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 13:26 [PATCH v2 0/3] Unnecessary code cleanup patches Abraham Samuel Adekunle
2025-04-03 13:26 ` [PATCH v2 1/3] staging: media: Remove duplicate NULL tests on a value in pci Abraham Samuel Adekunle
2025-04-03 13:31   ` Andy Shevchenko
2025-04-03 23:32     ` Samuel Abraham
2025-04-03 13:54   ` Greg KH
2025-04-03 14:19     ` Hans de Goede
2025-05-01 14:16   ` Hans de Goede
2025-04-03 13:26 ` [PATCH v2 2/3] staging: media: Remove duplicated NULL tests on a value in av7110 Abraham Samuel Adekunle
2025-04-03 13:35   ` Andy Shevchenko
2025-04-03 13:26 ` [PATCH v2 3/3] staging: rtl8723bs: Prevent duplicate NULL tests on a value Abraham Samuel Adekunle
2025-04-03 13:39   ` Andy Shevchenko [this message]
2025-04-03 23:34     ` Samuel Abraham

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=Z-6PlWGmn09hYYKU@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=abrahamadekunle50@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=outreachy@lists.linux.dev \
    --cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox