[PATCH v3 3/5] staging: rtl8188eu: use is_multicast_ether_addr in rtw_xmit.c

2018-08-10 Thread Michael Straube
Use is_multicast_ether_addr instead of custom IS_MCAST in
core/rtw_xmit.c. In all uses the address array is properly
aligned.

Signed-off-by: Michael Straube 
Reviewed-by: Dan Carpenter 
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 35 +++
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 2130d78e0d9f..fc06a13a6ea1 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -399,7 +399,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
struct sta_info *psta = NULL;
struct ethhdr etherhdr;
 
-   int bmcast;
+   bool mcast;
struct sta_priv *pstapriv = >stapriv;
struct security_priv*psecuritypriv = >securitypriv;
struct mlme_priv*pmlmepriv = >mlmepriv;
@@ -460,10 +460,10 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
if ((pattrib->ether_type == ETH_P_ARP) || (pattrib->ether_type == 
ETH_P_PAE) || (pattrib->dhcp_pkt == 1))
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
 
-   bmcast = IS_MCAST(pattrib->ra);
+   mcast = is_multicast_ether_addr(pattrib->ra);
 
/*  get sta_info */
-   if (bmcast) {
+   if (mcast) {
psta = rtw_get_bcmc_stainfo(padapter);
} else {
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
@@ -517,7 +517,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
goto exit;
}
} else {
-   GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
+   GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, mcast);
 
switch (psecuritypriv->dot11AuthAlgrthm) {
case dot11AuthAlgrthm_Open:
@@ -526,7 +526,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
pattrib->key_idx = 
(u8)psecuritypriv->dot11PrivacyKeyIndex;
break;
case dot11AuthAlgrthm_8021X:
-   if (bmcast)
+   if (mcast)
pattrib->key_idx = 
(u8)psecuritypriv->dot118021XGrpKeyid;
else
pattrib->key_idx = 0;
@@ -596,7 +596,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
struct  xmit_priv *pxmitpriv = >xmitpriv;
u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
u8 hw_hdr_offset = 0;
-   int bmcst = IS_MCAST(pattrib->ra);
 
if (pattrib->psta)
stainfo = pattrib->psta;
@@ -614,7 +613,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
 
pframe = pxmitframe->buf_addr + hw_hdr_offset;
 
-   if (bmcst) {
+   if (is_multicast_ether_addr(pattrib->ra)) {
if 
(!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey,
 null_key, 16))
return _FAIL;
/* start to calculate the mic code */
@@ -743,12 +742,10 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, 
struct pkt_attrib *pattr
 
struct sta_info *psta;
 
-   int bmcst = IS_MCAST(pattrib->ra);
-
if (pattrib->psta) {
psta = pattrib->psta;
} else {
-   if (bmcst)
+   if (is_multicast_ether_addr(pattrib->ra))
psta = rtw_get_bcmc_stainfo(padapter);
else
psta = rtw_get_stainfo(>stapriv, pattrib->ra);
@@ -914,7 +911,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct 
sk_buff *pkt, struct
struct xmit_priv*pxmitpriv = >xmitpriv;
struct pkt_attrib   *pattrib = >attrib;
u8 *pbuf_start;
-   s32 bmcst = IS_MCAST(pattrib->ra);
+   bool mcast = is_multicast_ether_addr(pattrib->ra);
s32 res = _SUCCESS;
size_t remainder = pkt->len - ETH_HLEN;
 
@@ -964,13 +961,13 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, 
struct sk_buff *pkt, struct
WEP_IV(pattrib->iv, psta->dot11txpn, 
pattrib->key_idx);
break;
case _TKIP_:
-   if (bmcst)
+   if (mcast)
TKIP_IV(pattrib->iv, psta->dot11txpn, 
pattrib->key_idx);
else
TKIP_IV(pattrib->iv, psta->dot11txpn, 
0);
break;
case _AES_:
-   if (bmcst)
+   

[PATCH v3 3/5] staging: rtl8188eu: use is_multicast_ether_addr in rtw_xmit.c

2018-08-10 Thread Michael Straube
Use is_multicast_ether_addr instead of custom IS_MCAST in
core/rtw_xmit.c. In all uses the address array is properly
aligned.

Signed-off-by: Michael Straube 
Reviewed-by: Dan Carpenter 
---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 35 +++
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c 
b/drivers/staging/rtl8188eu/core/rtw_xmit.c
index 2130d78e0d9f..fc06a13a6ea1 100644
--- a/drivers/staging/rtl8188eu/core/rtw_xmit.c
+++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c
@@ -399,7 +399,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
struct sta_info *psta = NULL;
struct ethhdr etherhdr;
 
-   int bmcast;
+   bool mcast;
struct sta_priv *pstapriv = >stapriv;
struct security_priv*psecuritypriv = >securitypriv;
struct mlme_priv*pmlmepriv = >mlmepriv;
@@ -460,10 +460,10 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
if ((pattrib->ether_type == ETH_P_ARP) || (pattrib->ether_type == 
ETH_P_PAE) || (pattrib->dhcp_pkt == 1))
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
 
-   bmcast = IS_MCAST(pattrib->ra);
+   mcast = is_multicast_ether_addr(pattrib->ra);
 
/*  get sta_info */
-   if (bmcast) {
+   if (mcast) {
psta = rtw_get_bcmc_stainfo(padapter);
} else {
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
@@ -517,7 +517,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
goto exit;
}
} else {
-   GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
+   GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, mcast);
 
switch (psecuritypriv->dot11AuthAlgrthm) {
case dot11AuthAlgrthm_Open:
@@ -526,7 +526,7 @@ static s32 update_attrib(struct adapter *padapter, struct 
sk_buff *pkt, struct p
pattrib->key_idx = 
(u8)psecuritypriv->dot11PrivacyKeyIndex;
break;
case dot11AuthAlgrthm_8021X:
-   if (bmcast)
+   if (mcast)
pattrib->key_idx = 
(u8)psecuritypriv->dot118021XGrpKeyid;
else
pattrib->key_idx = 0;
@@ -596,7 +596,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
struct  xmit_priv *pxmitpriv = >xmitpriv;
u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
u8 hw_hdr_offset = 0;
-   int bmcst = IS_MCAST(pattrib->ra);
 
if (pattrib->psta)
stainfo = pattrib->psta;
@@ -614,7 +613,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, 
struct xmit_frame *pxmitfr
 
pframe = pxmitframe->buf_addr + hw_hdr_offset;
 
-   if (bmcst) {
+   if (is_multicast_ether_addr(pattrib->ra)) {
if 
(!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey,
 null_key, 16))
return _FAIL;
/* start to calculate the mic code */
@@ -743,12 +742,10 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, 
struct pkt_attrib *pattr
 
struct sta_info *psta;
 
-   int bmcst = IS_MCAST(pattrib->ra);
-
if (pattrib->psta) {
psta = pattrib->psta;
} else {
-   if (bmcst)
+   if (is_multicast_ether_addr(pattrib->ra))
psta = rtw_get_bcmc_stainfo(padapter);
else
psta = rtw_get_stainfo(>stapriv, pattrib->ra);
@@ -914,7 +911,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct 
sk_buff *pkt, struct
struct xmit_priv*pxmitpriv = >xmitpriv;
struct pkt_attrib   *pattrib = >attrib;
u8 *pbuf_start;
-   s32 bmcst = IS_MCAST(pattrib->ra);
+   bool mcast = is_multicast_ether_addr(pattrib->ra);
s32 res = _SUCCESS;
size_t remainder = pkt->len - ETH_HLEN;
 
@@ -964,13 +961,13 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, 
struct sk_buff *pkt, struct
WEP_IV(pattrib->iv, psta->dot11txpn, 
pattrib->key_idx);
break;
case _TKIP_:
-   if (bmcst)
+   if (mcast)
TKIP_IV(pattrib->iv, psta->dot11txpn, 
pattrib->key_idx);
else
TKIP_IV(pattrib->iv, psta->dot11txpn, 
0);
break;
case _AES_:
-   if (bmcst)
+