From: Saurav Girepunje <saurav.girepunje@gmail.com>
To: gregkh@linuxfoundation.org, fabioaiuto83@gmail.com,
ross.schm.dev@gmail.com, deborahbrouwer3563@gmail.com,
hdegoede@redhat.com, marcocesati@gmail.com,
saurav.girepunje@gmail.com, phil@philpotter.co.uk,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: saurav.girepunje@hotmail.com
Subject: [PATCH] staging: rtl8723bs: core: simplify the if condition
Date: Sat, 9 Oct 2021 11:30:53 +0530 [thread overview]
Message-ID: <YWEwFf0YMi4W1xKN@user> (raw)
if psta is NULL, function is returning with fail. On next if condition
again checking if psta is not a NULL. Remove multiple if condition check.
Function is already using goto exit statement to exit.Replace multiple
return with goto exit statement.
Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_xmit.c | 61 ++++++++++-------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 34505b35a7f3..4e4a1bed882b 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -932,49 +932,40 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
/* TODO: fill HT Control Field */
/* Update Seq Num will be handled by f/w */
- {
- struct sta_info *psta;
-
- psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
- if (pattrib->psta != psta)
- return _FAIL;
-
- if (!psta)
- return _FAIL;
+ struct sta_info *psta;
- if (!(psta->state & _FW_LINKED))
- return _FAIL;
+ psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
+ if (!psta || pattrib->psta != psta || !(psta->state & _FW_LINKED))
+ res = _FAIL;
+ goto exit;
- if (psta) {
- psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
- psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
- pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
+ 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);
+ 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;
+ /* 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;
+ /* 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];
+ 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;
+ /* 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;
- pattrib->ampdu_en = true;/* AGG EN */
- } else {
- psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff;
- pattrib->ampdu_en = true;/* AGG EN */
- }
- }
+ pattrib->ampdu_en = true;/* AGG EN */
+ } else {
+ psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff;
+ pattrib->ampdu_en = true;/* AGG EN */
}
}
}
--
2.32.0
next reply other threads:[~2021-10-09 6:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-09 6:00 Saurav Girepunje [this message]
2021-10-09 16:51 ` [PATCH] staging: rtl8723bs: core: simplify the if condition Hans de Goede
2021-10-09 18:14 ` Saurav Girepunje
2021-10-11 12:09 ` Dan Carpenter
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=YWEwFf0YMi4W1xKN@user \
--to=saurav.girepunje@gmail.com \
--cc=deborahbrouwer3563@gmail.com \
--cc=fabioaiuto83@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=marcocesati@gmail.com \
--cc=phil@philpotter.co.uk \
--cc=ross.schm.dev@gmail.com \
--cc=saurav.girepunje@hotmail.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