Replace usage of RTLLIB_FCTL_DSTODS with function ieee80211_has_a4() to
avoid proprietary code and to increase readability. To achieve this goal
it was required to change a parameter of function rtllib_rx_data_filter().
Signed-off-by: Philipp Hortmann <[email protected]>
---
drivers/staging/rtl8192e/rtllib.h | 1 -
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 3 +--
drivers/staging/rtl8192e/rtllib_rx.c | 14 +++++++-------
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index 47156eb8f46b..9179c3c14ab3 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -338,7 +338,6 @@ enum rt_op_mode {
#define RTLLIB_FCTL_FRAMETYPE 0x00fc
#define RTLLIB_FCTL_TODS 0x0100
#define RTLLIB_FCTL_FROMDS 0x0200
-#define RTLLIB_FCTL_DSTODS 0x0300
#define RTLLIB_FCTL_MOREFRAGS 0x0400
#define RTLLIB_FCTL_RETRY 0x0800
#define RTLLIB_FCTL_PM 0x1000
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 8e4514cc132c..5621261d66b9 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -92,8 +92,7 @@ static int ccmp_init_iv_and_aad(struct ieee80211_hdr *hdr,
int a4_included, qc_included;
fc = le16_to_cpu(hdr->frame_control);
- a4_included = ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
- (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS));
+ a4_included = ieee80211_has_a4(hdr->frame_control);
qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) &&
(WLAN_FC_GET_STYPE(fc) & 0x80));
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 4d8c3869eb83..ef042dfd89cb 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -97,7 +97,7 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ if (ieee80211_has_a4(hdr->frame_control) &&
RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -166,7 +166,7 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ if (ieee80211_has_a4(hdr->frame_control) &&
RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -359,7 +359,7 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
struct ieee80211_qos_hdr_4addr *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ if (ieee80211_has_a4(header->frame_control) &&
RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct ieee80211_qos_hdr_4addr *)header;
tid = le16_to_cpu(hdr_4addrqos->qos_ctrl) & RTLLIB_QCTL_TID;
@@ -968,16 +968,16 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
}
}
-static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
+static int rtllib_rx_data_filter(struct rtllib_device *ieee, struct ieee80211_hdr *hdr,
u8 *dst, u8 *src, u8 *bssid, u8 *addr2)
{
u8 type, stype;
-
+ u16 fc = le16_to_cpu(hdr->frame_control);
type = WLAN_FC_GET_TYPE(fc);
stype = WLAN_FC_GET_STYPE(fc);
/* Filter frames from different BSS */
- if (((fc & RTLLIB_FCTL_DSTODS) != RTLLIB_FCTL_DSTODS) &&
+ if (ieee80211_has_a4(hdr->frame_control) &&
!ether_addr_equal(ieee->current_network.bssid, bssid) &&
!is_zero_ether_addr(ieee->current_network.bssid)) {
return -1;
@@ -1341,7 +1341,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid);
/* Filter Data frames */
- ret = rtllib_rx_data_filter(ieee, fc, dst, src, bssid, hdr->addr2);
+ ret = rtllib_rx_data_filter(ieee, hdr, dst, src, bssid, hdr->addr2);
if (ret < 0)
goto rx_dropped;
--
2.42.0