Commit 684d2f10 authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Greg Kroah-Hartman

staging: rtl8188eu: core: Use put_unaligned_le16

Introduce the use of function put_unaligned_le16.
This is done using the following Coccinelle semantic patch:

//<smpl>
@@ identifier tmp; expression ptr; expression y,e; type T; @@

- tmp = cpu_to_le16(y);

  <+... when != tmp
- memcpy(ptr, (T)&tmp, ...);
+ put_unaligned_le16(y,ptr);
  ...+>
? tmp = e

@@ type T; identifier tmp; @@

- T tmp;
...when != tmp
//</smpl>

Corresponding header file has been added too.
Signed-off-by: default avatarAmitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da04bf74
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define _RTW_MLME_EXT_C_ #define _RTW_MLME_EXT_C_
#include <linux/ieee80211.h> #include <linux/ieee80211.h>
#include <asm/unaligned.h>
#include <osdep_service.h> #include <osdep_service.h>
#include <drv_types.h> #include <drv_types.h>
...@@ -1027,7 +1028,6 @@ static void issue_assocreq(struct adapter *padapter) ...@@ -1027,7 +1028,6 @@ static void issue_assocreq(struct adapter *padapter)
unsigned char *pframe, *p; unsigned char *pframe, *p;
struct rtw_ieee80211_hdr *pwlanhdr; struct rtw_ieee80211_hdr *pwlanhdr;
__le16 *fctrl; __le16 *fctrl;
__le16 le_tmp;
unsigned int i, j, ie_len, index = 0; unsigned int i, j, ie_len, index = 0;
unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates];
struct ndis_802_11_var_ie *pIE; struct ndis_802_11_var_ie *pIE;
...@@ -1073,8 +1073,7 @@ static void issue_assocreq(struct adapter *padapter) ...@@ -1073,8 +1073,7 @@ static void issue_assocreq(struct adapter *padapter)
/* listen interval */ /* listen interval */
/* todo: listen interval for power saving */ /* todo: listen interval for power saving */
le_tmp = cpu_to_le16(3); put_unaligned_le16(3, pframe);
memcpy(pframe , (unsigned char *)&le_tmp, 2);
pframe += 2; pframe += 2;
pattrib->pktlen += 2; pattrib->pktlen += 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment