linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Kaiser <martin@kaiser.cx>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
	Phillip Potter <phil@philpotter.co.uk>,
	Michael Straube <straube.linux@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH 2/4] staging: r8188eu: use ieee80211 helpers to check the frame type
Date: Fri, 18 Feb 2022 14:50:36 +0100	[thread overview]
Message-ID: <20220218135038.908307-3-martin@kaiser.cx> (raw)
In-Reply-To: <20220218135038.908307-1-martin@kaiser.cx>

Use the ieee80211_is_... helper functions to check the frame type in
the validate_recv_frame function. Add a temporary variable for the
16-bit frame control field.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/core/rtw_recv.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c
index 955cc0a1638a..bb31423ec26c 100644
--- a/drivers/staging/r8188eu/core/rtw_recv.c
+++ b/drivers/staging/r8188eu/core/rtw_recv.c
@@ -3,6 +3,7 @@
 
 #define _RTW_RECV_C_
 
+#include <linux/ieee80211.h>
 #include "../include/osdep_service.h"
 #include "../include/drv_types.h"
 #include "../include/recv_osdep.h"
@@ -1056,12 +1057,12 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv
 
 	/* then call check if rx seq/frag. duplicated. */
 
-	u8 type;
 	u8 subtype;
 	int retval = _SUCCESS;
 	u8 bDumpRxPkt;
 	struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
 	u8 *ptr = precv_frame->rx_data;
+	__le16 fc = *(__le16 *)ptr;
 	u8  ver = (unsigned char)(*ptr) & 0x3;
 	struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
 
@@ -1077,7 +1078,6 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv
 		goto exit;
 	}
 
-	type =  GetFrameType(ptr);
 	subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */
 
 	pattrib->to_fr_ds = get_tofr_ds(ptr);
@@ -1093,16 +1093,14 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv
 
 	/* Dump rx packets */
 	GetHalDefVar8188EUsb(adapter, HAL_DEF_DBG_DUMP_RXPKT, &bDumpRxPkt);
-	switch (type) {
-	case IEEE80211_FTYPE_MGMT:
+
+	if (ieee80211_is_mgmt(fc)) {
 		validate_recv_mgnt_frame(adapter, precv_frame);
 		retval = _FAIL; /*  only data frame return _SUCCESS */
-		break;
-	case WIFI_CTRL_TYPE: /* ctrl */
+	} else if (ieee80211_is_ctl(fc)) {
 		validate_recv_ctrl_frame(adapter, precv_frame);
 		retval = _FAIL; /*  only data frame return _SUCCESS */
-		break;
-	case WIFI_DATA_TYPE: /* data */
+	} else if (ieee80211_is_data(fc)) {
 		rtw_led_control(adapter, LED_CTL_RX);
 		pattrib->qos = (subtype & BIT(7)) ? 1 : 0;
 		retval = validate_recv_data_frame(adapter, precv_frame);
@@ -1110,11 +1108,8 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv
 			struct recv_priv *precvpriv = &adapter->recvpriv;
 			precvpriv->rx_drop++;
 		}
-		break;
-	default:
+	} else
 		retval = _FAIL;
-		break;
-	}
 
 exit:
 
-- 
2.30.2


  parent reply	other threads:[~2022-02-18 13:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-18 13:50 [PATCH 0/4] staging: r8188eu: use ieee80211 defines and helpers Martin Kaiser
2022-02-18 13:50 ` [PATCH 1/4] staging: r8188eu: use ieee80211 define for management frame type Martin Kaiser
2022-02-18 13:50 ` Martin Kaiser [this message]
2022-02-18 13:50 ` [PATCH 3/4] staging: r8188eu: refactor validate_recv_frame's error handling Martin Kaiser
2022-02-18 13:50 ` [PATCH 4/4] staging: r8188eu: use ieee80211 helper for qos bit Martin Kaiser
2022-02-27 16:41 ` [PATCH v2 0/8] staging: r8188eu: use ieee80211 defines and helpers Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 1/8] staging: r8188eu: use ieee80211 define for management frame type Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 2/8] staging: r8188eu: use ieee80211 helpers to check the " Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 3/8] staging: r8188eu: refactor validate_recv_frame's error handling Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 4/8] staging: r8188eu: use ieee80211 helper for qos bit Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 5/8] staging: r8188eu: use ieee80211 helper to check for more fragments Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 6/8] staging: r8188eu: use ieee80211 helper to read "more data" Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 7/8] staging: r8188eu: use ieee80211 helper to read the protected bit Martin Kaiser
2022-02-27 16:41   ` [PATCH v2 8/8] staging: r8188eu: use ieee80211 helper to read the "order" bit Martin Kaiser

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=20220218135038.908307-3-martin@kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=Larry.Finger@lwfinger.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=phil@philpotter.co.uk \
    --cc=straube.linux@gmail.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;
as well as URLs for NNTP newsgroup(s).