aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2014-03-28 22:37:42 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-05 17:51:23 -0400
commitc17416ef707312429aafcdc4597db73906f3572e (patch)
tree7169a1b703ca4d42f3c12ec4cf28756b05512ff0
parent364e30ebd2dbaccba430c603da03e68746eb932a (diff)
staging: r8723au: Additional source patches
These changes are fixes that were discovered late in the testing cycle. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtl8723au/core/rtw_ap.c4
-rw-r--r--drivers/staging/rtl8723au/core/rtw_cmd.c8
-rw-r--r--drivers/staging/rtl8723au/core/rtw_efuse.c2
-rw-r--r--drivers/staging/rtl8723au/core/rtw_ieee80211.c24
-rw-r--r--drivers/staging/rtl8723au/core/rtw_mlme.c13
-rw-r--r--drivers/staging/rtl8723au/core/rtw_mlme_ext.c38
-rw-r--r--drivers/staging/rtl8723au/core/rtw_p2p.c280
-rw-r--r--drivers/staging/rtl8723au/core/rtw_pwrctrl.c39
-rw-r--r--drivers/staging/rtl8723au/core/rtw_security.c11
-rw-r--r--drivers/staging/rtl8723au/core/rtw_sreset.c2
-rw-r--r--drivers/staging/rtl8723au/core/rtw_wlan_util.c2
-rw-r--r--drivers/staging/rtl8723au/core/rtw_xmit.c7
-rw-r--r--drivers/staging/rtl8723au/hal/hal_intf.c2
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c10
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c2
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723au_xmit.c2
-rw-r--r--drivers/staging/rtl8723au/include/Hal8723APhyCfg.h2
-rw-r--r--drivers/staging/rtl8723au/include/drv_types.h4
-rw-r--r--drivers/staging/rtl8723au/include/odm.h17
-rw-r--r--drivers/staging/rtl8723au/include/odm_HWConfig.h16
-rw-r--r--drivers/staging/rtl8723au/include/osdep_service.h133
-rw-r--r--drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h4
-rw-r--r--drivers/staging/rtl8723au/include/rtl8723a_pg.h23
-rw-r--r--drivers/staging/rtl8723au/include/rtw_mlme.h52
-rw-r--r--drivers/staging/rtl8723au/include/rtw_mlme_ext.h2
-rw-r--r--drivers/staging/rtl8723au/include/rtw_pwrctrl.h2
-rw-r--r--drivers/staging/rtl8723au/include/rtw_recv.h11
-rw-r--r--drivers/staging/rtl8723au/include/sta_info.h15
-rw-r--r--drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c55
-rw-r--r--drivers/staging/rtl8723au/os_dep/osdep_service.c254
-rw-r--r--drivers/staging/rtl8723au/os_dep/usb_intf.c7
31 files changed, 343 insertions, 700 deletions
diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c
index 3d936eb937ef..a357e98cb83e 100644
--- a/drivers/staging/rtl8723au/core/rtw_ap.c
+++ b/drivers/staging/rtl8723au/core/rtw_ap.c
@@ -842,10 +842,10 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len)
842 /* beacon interval */ 842 /* beacon interval */
843 /* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ 843 /* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */
844 p = rtw_get_beacon_interval23a_from_ie(ie); 844 p = rtw_get_beacon_interval23a_from_ie(ie);
845 pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p); 845 pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p);
846 846
847 /* capability */ 847 /* capability */
848 cap = RTW_GET_LE16(ie); 848 cap = get_unaligned_le16(ie);
849 849
850 /* SSID */ 850 /* SSID */
851 p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, 851 p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len,
diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c
index dbc6401c6e13..5e3088a01800 100644
--- a/drivers/staging/rtl8723au/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
@@ -447,7 +447,7 @@ _next:
447 447
448 pcmdpriv->cmd_issued_cnt++; 448 pcmdpriv->cmd_issued_cnt++;
449 449
450 pcmd->cmdsz = _RND4(pcmd->cmdsz);/* _RND4 */ 450 pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4);
451 451
452 memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); 452 memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
453 453
@@ -1141,7 +1141,9 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter)
1141 u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false; 1141 u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false;
1142 u8 bHigherBusyTxTraffic = false; 1142 u8 bHigherBusyTxTraffic = false;
1143 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1143 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1144 1144#ifndef CONFIG_8723AU_BT_COEXIST
1145 int BusyThreshold = 100;
1146#endif
1145 /* */ 1147 /* */
1146 /* Determine if our traffic is busy now */ 1148 /* Determine if our traffic is busy now */
1147 /* */ 1149 /* */
@@ -1638,12 +1640,12 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf)
1638 case P2P_PS_WK_CID: 1640 case P2P_PS_WK_CID:
1639 p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size); 1641 p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
1640 break; 1642 break;
1641#endif /* CONFIG_8723AU_P2P */
1642 case P2P_PROTO_WK_CID: 1643 case P2P_PROTO_WK_CID:
1643 /* Commented by Albert 2011/07/01 */ 1644 /* Commented by Albert 2011/07/01 */
1644 /* I used the type_size as the type command */ 1645 /* I used the type_size as the type command */
1645 p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size); 1646 p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size);
1646 break; 1647 break;
1648#endif /* CONFIG_8723AU_P2P */
1647#ifdef CONFIG_8723AU_AP_MODE 1649#ifdef CONFIG_8723AU_AP_MODE
1648 case CHECK_HIQ_WK_CID: 1650 case CHECK_HIQ_WK_CID:
1649 rtw_chk_hi_queue_hdl(padapter); 1651 rtw_chk_hi_queue_hdl(padapter);
diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c
index 94221ee45bd2..35b177fd0510 100644
--- a/drivers/staging/rtl8723au/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723au/core/rtw_efuse.c
@@ -108,7 +108,6 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf)
108 u32 value32; 108 u32 value32;
109 u8 readbyte; 109 u8 readbyte;
110 u16 retry; 110 u16 retry;
111 /* u32 start = rtw_get_current_time(); */
112 111
113 /* Write Address */ 112 /* Write Address */
114 rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); 113 rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff));
@@ -137,7 +136,6 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf)
137 value32 = rtw_read32(Adapter, EFUSE_CTRL); 136 value32 = rtw_read32(Adapter, EFUSE_CTRL);
138 137
139 *pbuf = (u8)(value32 & 0xff); 138 *pbuf = (u8)(value32 & 0xff);
140 /* DBG_8723A("ReadEFuseByte23a _offset:%08u, in %d ms\n", _offset , rtw_get_passing_time_ms23a(start)); */
141} 139}
142 140
143/* */ 141/* */
diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
index 8287f447cbdd..780631fd3b6d 100644
--- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
@@ -196,8 +196,8 @@ inline u8 *rtw_set_ie23a_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl,
196 196
197 ie_data[0] = ttl; 197 ie_data[0] = ttl;
198 ie_data[1] = flags; 198 ie_data[1] = flags;
199 RTW_PUT_LE16((u8*)&ie_data[2], reason); 199 put_unaligned_le16(reason, (u8*)&ie_data[2]);
200 RTW_PUT_LE16((u8*)&ie_data[4], precedence); 200 put_unaligned_le16(precedence, (u8*)&ie_data[4]);
201 201
202 return rtw_set_ie23a(buf, 0x118, 6, ie_data, buf_len); 202 return rtw_set_ie23a(buf, 0x118, 6, ie_data, buf_len);
203} 203}
@@ -585,7 +585,7 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair
585 /* pairwise_cipher */ 585 /* pairwise_cipher */
586 if (left >= 2) { 586 if (left >= 2) {
587 /* count = le16_to_cpu(*(u16*)pos); */ 587 /* count = le16_to_cpu(*(u16*)pos); */
588 count = RTW_GET_LE16(pos); 588 count = get_unaligned_le16(pos);
589 pos += 2; 589 pos += 2;
590 left -= 2; 590 left -= 2;
591 591
@@ -661,7 +661,7 @@ int rtw_parse_wpa2_ie23a(u8* rsn_ie, int rsn_ie_len, int *group_cipher,
661 /* pairwise_cipher */ 661 /* pairwise_cipher */
662 if (left >= 2) { 662 if (left >= 2) {
663 /* count = le16_to_cpu(*(u16*)pos); */ 663 /* count = le16_to_cpu(*(u16*)pos); */
664 count = RTW_GET_LE16(pos); 664 count = get_unaligned_le16(pos);
665 pos += 2; 665 pos += 2;
666 left -= 2; 666 left -= 2;
667 667
@@ -876,8 +876,8 @@ u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id,
876 876
877 while (attr_ptr - wps_ie < wps_ielen) { 877 while (attr_ptr - wps_ie < wps_ielen) {
878 /* 4 = 2(Attribute ID) + 2(Length) */ 878 /* 4 = 2(Attribute ID) + 2(Length) */
879 u16 attr_id = RTW_GET_BE16(attr_ptr); 879 u16 attr_id = get_unaligned_be16(attr_ptr);
880 u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2); 880 u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
881 u16 attr_len = attr_data_len + 4; 881 u16 attr_len = attr_data_len + 4;
882 882
883 /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */ 883 /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
@@ -1246,8 +1246,8 @@ void dump_wps_ie23a(u8 *ie, u32 ie_len) {
1246 1246
1247 pos+= 6; 1247 pos+= 6;
1248 while (pos-ie < ie_len) { 1248 while (pos-ie < ie_len) {
1249 id = RTW_GET_BE16(pos); 1249 id = get_unaligned_be16(pos);
1250 len = RTW_GET_BE16(pos + 2); 1250 len = get_unaligned_be16(pos + 2);
1251 1251
1252 DBG_8723A("%s ID:0x%04x, LEN:%u\n", __func__, id, len); 1252 DBG_8723A("%s ID:0x%04x, LEN:%u\n", __func__, id, len);
1253 1253
@@ -1271,7 +1271,7 @@ void dump_p2p_ie23a(u8 *ie, u32 ie_len) {
1271 pos += 6; 1271 pos += 6;
1272 while (pos-ie < ie_len) { 1272 while (pos-ie < ie_len) {
1273 id = *pos; 1273 id = *pos;
1274 len = RTW_GET_LE16(pos+1); 1274 len = get_unaligned_le16(pos+1);
1275 1275
1276 DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); 1276 DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len);
1277 1277
@@ -1362,7 +1362,7 @@ u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id,
1362 while (attr_ptr - p2p_ie < p2p_ielen) { 1362 while (attr_ptr - p2p_ie < p2p_ielen) {
1363 /* 3 = 1(Attribute ID) + 2(Length) */ 1363 /* 3 = 1(Attribute ID) + 2(Length) */
1364 u8 attr_id = *attr_ptr; 1364 u8 attr_id = *attr_ptr;
1365 u16 attr_data_len = RTW_GET_LE16(attr_ptr + 1); 1365 u16 attr_data_len = get_unaligned_le16(attr_ptr + 1);
1366 u16 attr_len = attr_data_len + 3; 1366 u16 attr_len = attr_data_len + 3;
1367 1367
1368 /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */ 1368 /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
@@ -1429,7 +1429,7 @@ u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_at
1429 *pbuf = attr_id; 1429 *pbuf = attr_id;
1430 1430
1431 /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ 1431 /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */
1432 RTW_PUT_LE16(pbuf + 1, attr_len); 1432 put_unaligned_le16(attr_len, pbuf + 1);
1433 1433
1434 if (pdata_attr) 1434 if (pdata_attr)
1435 memcpy(pbuf + 3, pdata_attr, attr_len); 1435 memcpy(pbuf + 3, pdata_attr, attr_len);
@@ -1561,7 +1561,7 @@ int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id,
1561 /* 1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */ 1561 /* 1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */
1562 cnt = 6; 1562 cnt = 6;
1563 while (cnt < wfd_ielen) { 1563 while (cnt < wfd_ielen) {
1564 u16 attrlen = RTW_GET_BE16(wfd_ie + cnt + 1); 1564 u16 attrlen = get_unaligned_be16(wfd_ie + cnt + 1);
1565 1565
1566 attr_id = wfd_ie[cnt]; 1566 attr_id = wfd_ie[cnt];
1567 if (attr_id == target_attr_id) { 1567 if (attr_id == target_attr_id) {
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index 71749a37a78e..6cee78785bdc 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -69,6 +69,7 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
69 return res; 69 return res;
70} 70}
71 71
72#ifdef CONFIG_8723AU_AP_MODE
72static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) 73static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen)
73{ 74{
74 if(*ppie) 75 if(*ppie)
@@ -78,6 +79,7 @@ static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen)
78 *ppie=NULL; 79 *ppie=NULL;
79 } 80 }
80} 81}
82#endif
81 83
82void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) 84void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
83{ 85{
@@ -94,9 +96,7 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
94 rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); 96 rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len);
95 rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); 97 rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len);
96 rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); 98 rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len);
97#endif
98 99
99#if defined(CONFIG_8723AU_P2P)
100 rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len); 100 rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len);
101 rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len); 101 rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len);
102 rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len); 102 rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len);
@@ -941,7 +941,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter)
941 941
942 /* set ips_deny_time to avoid enter IPS before LPS leave */ 942 /* set ips_deny_time to avoid enter IPS before LPS leave */
943 padapter->pwrctrlpriv.ips_deny_time = 943 padapter->pwrctrlpriv.ips_deny_time =
944 rtw_get_current_time() + rtw_ms_to_systime23a(3000); 944 jiffies + msecs_to_jiffies(3000);
945 945
946 _clr_fwstate_(pmlmepriv, _FW_LINKED); 946 _clr_fwstate_(pmlmepriv, _FW_LINKED);
947 947
@@ -1675,7 +1675,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv
1675 } 1675 }
1676 1676
1677 /* check ssid, if needed */ 1677 /* check ssid, if needed */
1678 if (pmlmepriv->assoc_ssid.ssid && pmlmepriv->assoc_ssid.ssid_len) { 1678 if (pmlmepriv->assoc_ssid.ssid_len) {
1679 if (competitor->network.Ssid.ssid_len != 1679 if (competitor->network.Ssid.ssid_len !=
1680 pmlmepriv->assoc_ssid.ssid_len || 1680 pmlmepriv->assoc_ssid.ssid_len ||
1681 memcmp(competitor->network.Ssid.ssid, 1681 memcmp(competitor->network.Ssid.ssid,
@@ -1839,8 +1839,7 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
1839 res = _FAIL; /* try again */ 1839 res = _FAIL; /* try again */
1840 goto exit; 1840 goto exit;
1841 } 1841 }
1842 psetkeyparm = (struct setkey_parm *) 1842 psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
1843 kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
1844 if (!psetkeyparm) { 1843 if (!psetkeyparm) {
1845 kfree(pcmd); 1844 kfree(pcmd);
1846 res = _FAIL; 1845 res = _FAIL;
@@ -1902,6 +1901,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
1902 "%x (must be 1 or 2 or 4 or 5)\n", 1901 "%x (must be 1 or 2 or 4 or 5)\n",
1903 psecuritypriv->dot11PrivacyAlgrthm)); 1902 psecuritypriv->dot11PrivacyAlgrthm));
1904 res = _FAIL; 1903 res = _FAIL;
1904 kfree(pcmd);
1905 kfree(psetkeyparm);
1905 goto exit; 1906 goto exit;
1906 } 1907 }
1907 1908
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index 75ccdec881e5..4c753639ea5a 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -762,9 +762,9 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter,
762 struct recv_frame *precv_frame) 762 struct recv_frame *precv_frame)
763{ 763{
764 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 764 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
765#ifdef CONFIG_8723AU_P2P
765 struct sk_buff *skb = precv_frame->pkt; 766 struct sk_buff *skb = precv_frame->pkt;
766 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 767 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
767#ifdef CONFIG_8723AU_P2P
768 struct wifidirect_info *pwdinfo = &padapter->wdinfo; 768 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
769#endif 769#endif
770 770
@@ -1309,10 +1309,10 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
1309 goto asoc_class2_error; 1309 goto asoc_class2_error;
1310 } 1310 }
1311 1311
1312 capab_info = RTW_GET_LE16(pframe + sizeof(struct ieee80211_hdr_3addr)); 1312 capab_info = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr));
1313 /* capab_info = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); */ 1313 /* capab_info = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); */
1314 /* listen_interval = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)+2)); */ 1314 /* listen_interval = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)+2)); */
1315 listen_interval = RTW_GET_LE16(pframe + sizeof(struct ieee80211_hdr_3addr)+2); 1315 listen_interval = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)+2);
1316 1316
1317 left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset); 1317 left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
1318 pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset); 1318 pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset);
@@ -1665,7 +1665,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec
1665 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); 1665 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
1666 if (attr_contentlen) 1666 if (attr_contentlen)
1667 { 1667 {
1668 pwdinfo->wfd_info->peer_rtsp_ctrlport = RTW_GET_BE16(attr_content + 2); 1668 pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
1669 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); 1669 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
1670 } 1670 }
1671 } 1671 }
@@ -2091,7 +2091,7 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
2091 } 2091 }
2092 break; 2092 break;
2093 case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ 2093 case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
2094 status = RTW_GET_LE16(&frame_body[3]); 2094 status = get_unaligned_le16(&frame_body[3]);
2095 tid = ((frame_body[5] >> 2) & 0x7); 2095 tid = ((frame_body[5] >> 2) & 0x7);
2096 if (status == 0) { /* successful */ 2096 if (status == 0) { /* successful */
2097 DBG_8723A("agg_enable for TID =%d\n", tid); 2097 DBG_8723A("agg_enable for TID =%d\n", tid);
@@ -2110,7 +2110,7 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame
2110 ~(1 << ((frame_body[3] >> 4) & 0xf)); 2110 ~(1 << ((frame_body[3] >> 4) & 0xf));
2111 2111
2112 /* reason_code = frame_body[4] | (frame_body[5] << 8); */ 2112 /* reason_code = frame_body[4] | (frame_body[5] << 8); */
2113 reason_code = RTW_GET_LE16(&frame_body[4]); 2113 reason_code = get_unaligned_le16(&frame_body[4]);
2114 } else if ((frame_body[3] & BIT(3)) == BIT(3)) { 2114 } else if ((frame_body[3] & BIT(3)) == BIT(3)) {
2115 tid = (frame_body[3] >> 4) & 0x0F; 2115 tid = (frame_body[3] >> 4) & 0x0F;
2116 2116
@@ -4531,14 +4531,14 @@ static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token)
4531 4531
4532static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) 4532static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame)
4533{ 4533{
4534 struct rtw_adapter *padapter = precv_frame->adapter;
4535 struct sk_buff *skb = precv_frame->pkt; 4534 struct sk_buff *skb = precv_frame->pkt;
4536 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4537 u8 *pframe = skb->data; 4535 u8 *pframe = skb->data;
4538 uint len = skb->len;
4539 u8 *frame_body; 4536 u8 *frame_body;
4540 u8 dialogToken = 0; 4537 u8 dialogToken = 0;
4541#ifdef CONFIG_8723AU_P2P 4538#ifdef CONFIG_8723AU_P2P
4539 struct rtw_adapter *padapter = precv_frame->adapter;
4540 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
4541 uint len = skb->len;
4542 u8 *p2p_ie; 4542 u8 *p2p_ie;
4543 u32 p2p_ielen; 4543 u32 p2p_ielen;
4544 struct wifidirect_info *pwdinfo = &padapter->wdinfo; 4544 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
@@ -5262,9 +5262,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms)
5262 unsigned short *fctrl; 5262 unsigned short *fctrl;
5263 unsigned int rate_len; 5263 unsigned int rate_len;
5264 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 5264 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
5265#ifdef CONFIG_8723AU_AP_MODE
5266 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 5265 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
5267#endif
5268 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5266 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
5269 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; 5267 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
5270 struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; 5268 struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
@@ -5579,6 +5577,13 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
5579#ifdef CONFIG_8723AU_AP_MODE 5577#ifdef CONFIG_8723AU_AP_MODE
5580 u8 *pwps_ie; 5578 u8 *pwps_ie;
5581 uint wps_ielen; 5579 uint wps_ielen;
5580 u8 *ssid_ie;
5581 int ssid_ielen;
5582 int ssid_ielen_diff;
5583 u8 buf[MAX_IE_SZ];
5584 u8 *ies;
5585#endif
5586#if defined(CONFIG_8723AU_AP_MODE) || defined(CONFIG_8723AU_P2P)
5582 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 5587 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
5583#endif 5588#endif
5584 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 5589 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -5588,11 +5593,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da,
5588#ifdef CONFIG_8723AU_P2P 5593#ifdef CONFIG_8723AU_P2P
5589 struct wifidirect_info *pwdinfo = &padapter->wdinfo; 5594 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
5590#endif /* CONFIG_8723AU_P2P */ 5595#endif /* CONFIG_8723AU_P2P */
5591 u8 *ssid_ie;
5592 int ssid_ielen;
5593 int ssid_ielen_diff;
5594 u8 buf[MAX_IE_SZ];
5595 u8 *ies;
5596 5596
5597 /* DBG_8723A("%s\n", __func__); */ 5597 /* DBG_8723A("%s\n", __func__); */
5598 5598
@@ -7559,6 +7559,7 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter)
7559 int issue = 0; 7559 int issue = 0;
7560 int poll = 0; 7560 int poll = 0;
7561 unsigned long start = jiffies; 7561 unsigned long start = jiffies;
7562 unsigned int passing_time;
7562 7563
7563 rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_VALID, NULL); 7564 rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_VALID, NULL);
7564 do { 7565 do {
@@ -7578,11 +7579,12 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter)
7578 if (padapter->bSurpriseRemoved || padapter->bDriverStopped) 7579 if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
7579 return _FAIL; 7580 return _FAIL;
7580 7581
7582 passing_time = jiffies_to_msecs(jiffies - start);
7583
7581 if (!bxmitok) { 7584 if (!bxmitok) {
7582 DBG_8723A("%s fail! %u ms\n", __func__, rtw_get_passing_time_ms23a(start)); 7585 DBG_8723A("%s fail! %u ms\n", __func__, passing_time);
7583 return _FAIL; 7586 return _FAIL;
7584 } else { 7587 } else {
7585 unsigned int passing_time = jiffies_to_msecs(jiffies - start);
7586 7588
7587 if (passing_time > 100 || issue > 3) 7589 if (passing_time > 100 || issue > 3)
7588 DBG_8723A("%s success, issue:%d, poll:%d, %u ms\n", 7590 DBG_8723A("%s success, issue:%d, poll:%d, %u ms\n",
diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c
index becc3feaca1d..27a6cc76973d 100644
--- a/drivers/staging/rtl8723au/core/rtw_p2p.c
+++ b/drivers/staging/rtl8723au/core/rtw_p2p.c
@@ -81,7 +81,7 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
81 pcur++; 81 pcur++;
82 82
83 /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ 83 /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */
84 RTW_PUT_BE16(pcur, psta->config_methods); 84 put_unaligned_be16(psta->config_methods, pcur);
85 pcur += 2; 85 pcur += 2;
86 86
87 memcpy(pcur, psta->primary_dev_type, 8); 87 memcpy(pcur, psta->primary_dev_type, 8);
@@ -96,11 +96,11 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
96 if (psta->dev_name_len>0) 96 if (psta->dev_name_len>0)
97 { 97 {
98 /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ 98 /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
99 RTW_PUT_BE16(pcur, WPS_ATTR_DEVICE_NAME); 99 put_unaligned_be16(WPS_ATTR_DEVICE_NAME, pcur);
100 pcur += 2; 100 pcur += 2;
101 101
102 /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ 102 /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */
103 RTW_PUT_BE16(pcur, psta->dev_name_len); 103 put_unaligned_be16(psta->dev_name_len, pcur);
104 pcur += 2; 104 pcur += 2;
105 105
106 memcpy(pcur, psta->dev_name, psta->dev_name_len); 106 memcpy(pcur, psta->dev_name, psta->dev_name_len);
@@ -320,23 +320,23 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr,
320 wpsielen = 0; 320 wpsielen = 0;
321 /* WPS OUI */ 321 /* WPS OUI */
322 /* u32*) (wpsie) = cpu_to_be32(WPSOUI); */ 322 /* u32*) (wpsie) = cpu_to_be32(WPSOUI); */
323 RTW_PUT_BE32(wpsie, WPSOUI); 323 put_unaligned_be32(WPSOUI, wpsie);
324 wpsielen += 4; 324 wpsielen += 4;
325 325
326 /* Config Method */ 326 /* Config Method */
327 /* Type: */ 327 /* Type: */
328 /* u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); */ 328 /* u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); */
329 RTW_PUT_BE16(wpsie + wpsielen, WPS_ATTR_CONF_METHOD); 329 put_unaligned_be16(WPS_ATTR_CONF_METHOD, wpsie + wpsielen);
330 wpsielen += 2; 330 wpsielen += 2;
331 331
332 /* Length: */ 332 /* Length: */
333 /* u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); */ 333 /* u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); */
334 RTW_PUT_BE16(wpsie + wpsielen, 0x0002); 334 put_unaligned_be16(0x0002, wpsie + wpsielen);
335 wpsielen += 2; 335 wpsielen += 2;
336 336
337 /* Value: */ 337 /* Value: */
338 /* u16*) (wpsie + wpsielen) = cpu_to_be16(config_method); */ 338 /* u16*) (wpsie + wpsielen) = cpu_to_be16(config_method); */
339 RTW_PUT_BE16(wpsie + wpsielen, config_method); 339 put_unaligned_be16(config_method, wpsie + wpsielen);
340 wpsielen += 2; 340 wpsielen += 2;
341 341
342 pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); 342 pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen);
@@ -513,7 +513,7 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
513 513
514 /* Length: */ 514 /* Length: */
515 /* Note: In the WFD specification, the size of length field is 2. */ 515 /* Note: In the WFD specification, the size of length field is 2. */
516 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 516 put_unaligned_be16(0x0006, wfdie + wfdielen);
517 wfdielen += 2; 517 wfdielen += 2;
518 518
519 /* Value1: */ 519 /* Value1: */
@@ -524,19 +524,24 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
524 if (is_any_client_associated(pwdinfo->padapter)) 524 if (is_any_client_associated(pwdinfo->padapter))
525 { 525 {
526 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) */ 526 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) */
527 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD); 527 put_unaligned_be16(pwfd_info->wfd_device_type |
528 WFD_DEVINFO_WSD, wfdie + wfdielen);
528 } 529 }
529 else 530 else
530 { 531 {
531 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 532 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
532 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 533 put_unaligned_be16(pwfd_info->wfd_device_type |
534 WFD_DEVINFO_SESSION_AVAIL |
535 WFD_DEVINFO_WSD, wfdie + wfdielen);
533 } 536 }
534 537
535 } 538 }
536 else 539 else
537 { 540 {
538 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 541 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
539 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 542 put_unaligned_be16(pwfd_info->wfd_device_type |
543 WFD_DEVINFO_SESSION_AVAIL |
544 WFD_DEVINFO_WSD, wfdie + wfdielen);
540 } 545 }
541 546
542 wfdielen += 2; 547 wfdielen += 2;
@@ -544,13 +549,13 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
544 /* Value2: */ 549 /* Value2: */
545 /* Session Management Control Port */ 550 /* Session Management Control Port */
546 /* Default TCP port for RTSP messages is 554 */ 551 /* Default TCP port for RTSP messages is 554 */
547 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 552 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
548 wfdielen += 2; 553 wfdielen += 2;
549 554
550 /* Value3: */ 555 /* Value3: */
551 /* WFD Device Maximum Throughput */ 556 /* WFD Device Maximum Throughput */
552 /* 300Mbps is the maximum throughput */ 557 /* 300Mbps is the maximum throughput */
553 RTW_PUT_BE16(wfdie + wfdielen, 300); 558 put_unaligned_be16(300, wfdie + wfdielen);
554 wfdielen += 2; 559 wfdielen += 2;
555 560
556 /* Associated BSSID ATTR */ 561 /* Associated BSSID ATTR */
@@ -559,7 +564,7 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
559 564
560 /* Length: */ 565 /* Length: */
561 /* Note: In the WFD specification, the size of length field is 2. */ 566 /* Note: In the WFD specification, the size of length field is 2. */
562 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 567 put_unaligned_be16(0x0006, wfdie + wfdielen);
563 wfdielen += 2; 568 wfdielen += 2;
564 569
565 /* Value: */ 570 /* Value: */
@@ -581,7 +586,7 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
581 586
582 /* Length: */ 587 /* Length: */
583 /* Note: In the WFD specification, the size of length field is 2. */ 588 /* Note: In the WFD specification, the size of length field is 2. */
584 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 589 put_unaligned_be16(0x0007, wfdie + wfdielen);
585 wfdielen += 2; 590 wfdielen += 2;
586 591
587 /* Value: */ 592 /* Value: */
@@ -628,7 +633,7 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
628 633
629 /* Length: */ 634 /* Length: */
630 /* Note: In the WFD specification, the size of length field is 2. */ 635 /* Note: In the WFD specification, the size of length field is 2. */
631 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 636 put_unaligned_be16(0x0006, wfdie + wfdielen);
632 wfdielen += 2; 637 wfdielen += 2;
633 638
634 /* Value1: */ 639 /* Value1: */
@@ -637,17 +642,17 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
637 if (1 == pwdinfo->wfd_tdls_enable) 642 if (1 == pwdinfo->wfd_tdls_enable)
638 { 643 {
639 /* WFD primary sink + available for WFD session + WiFi TDLS mode + WSC (WFD Service Discovery) */ 644 /* WFD primary sink + available for WFD session + WiFi TDLS mode + WSC (WFD Service Discovery) */
640 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | 645 put_unaligned_be16(pwfd_info->wfd_device_type |
641 WFD_DEVINFO_SESSION_AVAIL | 646 WFD_DEVINFO_SESSION_AVAIL |
642 WFD_DEVINFO_WSD | 647 WFD_DEVINFO_WSD |
643 WFD_DEVINFO_PC_TDLS); 648 WFD_DEVINFO_PC_TDLS, wfdie + wfdielen);
644 } 649 }
645 else 650 else
646 { 651 {
647 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSC (WFD Service Discovery) */ 652 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSC (WFD Service Discovery) */
648 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | 653 put_unaligned_be16(pwfd_info->wfd_device_type |
649 WFD_DEVINFO_SESSION_AVAIL | 654 WFD_DEVINFO_SESSION_AVAIL |
650 WFD_DEVINFO_WSD); 655 WFD_DEVINFO_WSD, wfdie + wfdielen);
651 } 656 }
652 657
653 wfdielen += 2; 658 wfdielen += 2;
@@ -655,13 +660,13 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
655 /* Value2: */ 660 /* Value2: */
656 /* Session Management Control Port */ 661 /* Session Management Control Port */
657 /* Default TCP port for RTSP messages is 554 */ 662 /* Default TCP port for RTSP messages is 554 */
658 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 663 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
659 wfdielen += 2; 664 wfdielen += 2;
660 665
661 /* Value3: */ 666 /* Value3: */
662 /* WFD Device Maximum Throughput */ 667 /* WFD Device Maximum Throughput */
663 /* 300Mbps is the maximum throughput */ 668 /* 300Mbps is the maximum throughput */
664 RTW_PUT_BE16(wfdie + wfdielen, 300); 669 put_unaligned_be16(300, wfdie + wfdielen);
665 wfdielen += 2; 670 wfdielen += 2;
666 671
667 /* Associated BSSID ATTR */ 672 /* Associated BSSID ATTR */
@@ -670,7 +675,7 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
670 675
671 /* Length: */ 676 /* Length: */
672 /* Note: In the WFD specification, the size of length field is 2. */ 677 /* Note: In the WFD specification, the size of length field is 2. */
673 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 678 put_unaligned_be16(0x0006, wfdie + wfdielen);
674 wfdielen += 2; 679 wfdielen += 2;
675 680
676 /* Value: */ 681 /* Value: */
@@ -692,7 +697,7 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
692 697
693 /* Length: */ 698 /* Length: */
694 /* Note: In the WFD specification, the size of length field is 2. */ 699 /* Note: In the WFD specification, the size of length field is 2. */
695 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 700 put_unaligned_be16(0x0007, wfdie + wfdielen);
696 wfdielen += 2; 701 wfdielen += 2;
697 702
698 /* Value: */ 703 /* Value: */
@@ -740,7 +745,7 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
740 745
741 /* Length: */ 746 /* Length: */
742 /* Note: In the WFD specification, the size of length field is 2. */ 747 /* Note: In the WFD specification, the size of length field is 2. */
743 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 748 put_unaligned_be16(0x0006, wfdie + wfdielen);
744 wfdielen += 2; 749 wfdielen += 2;
745 750
746 /* Value1: */ 751 /* Value1: */
@@ -756,12 +761,12 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
756 if (pwdinfo->wfd_tdls_enable) 761 if (pwdinfo->wfd_tdls_enable)
757 { 762 {
758 /* TDLS mode + WSD (WFD Service Discovery) */ 763 /* TDLS mode + WSD (WFD Service Discovery) */
759 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT); 764 put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
760 } 765 }
761 else 766 else
762 { 767 {
763 /* WiFi Direct mode + WSD (WFD Service Discovery) */ 768 /* WiFi Direct mode + WSD (WFD Service Discovery) */
764 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT); 769 put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
765 } 770 }
766 } 771 }
767 else 772 else
@@ -769,12 +774,12 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
769 if (pwdinfo->wfd_tdls_enable) 774 if (pwdinfo->wfd_tdls_enable)
770 { 775 {
771 /* available for WFD session + TDLS mode + WSD (WFD Service Discovery) */ 776 /* available for WFD session + TDLS mode + WSD (WFD Service Discovery) */
772 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT); 777 put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
773 } 778 }
774 else 779 else
775 { 780 {
776 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 781 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
777 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT); 782 put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen);
778 } 783 }
779 } 784 }
780 } 785 }
@@ -783,13 +788,22 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
783 if (pwdinfo->wfd_tdls_enable) 788 if (pwdinfo->wfd_tdls_enable)
784 { 789 {
785 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 790 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
786 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT); 791 put_unaligned_be16(pwfd_info->wfd_device_type |
792 WFD_DEVINFO_SESSION_AVAIL |
793 WFD_DEVINFO_WSD |
794 WFD_DEVINFO_PC_TDLS |
795 WFD_DEVINFO_HDCP_SUPPORT,
796 wfdie + wfdielen);
787 } 797 }
788 else 798 else
789 { 799 {
790 800
791 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 801 /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
792 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT); 802 put_unaligned_be16(pwfd_info->wfd_device_type |
803 WFD_DEVINFO_SESSION_AVAIL |
804 WFD_DEVINFO_WSD |
805 WFD_DEVINFO_HDCP_SUPPORT,
806 wfdie + wfdielen);
793 } 807 }
794 } 808 }
795 } 809 }
@@ -797,11 +811,18 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
797 { 811 {
798 if (pwdinfo->wfd_tdls_enable) 812 if (pwdinfo->wfd_tdls_enable)
799 { 813 {
800 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD |WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT); 814 put_unaligned_be16(pwfd_info->wfd_device_type |
815 WFD_DEVINFO_WSD |
816 WFD_DEVINFO_PC_TDLS |
817 WFD_DEVINFO_HDCP_SUPPORT,
818 wfdie + wfdielen);
801 } 819 }
802 else 820 else
803 { 821 {
804 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT); 822 put_unaligned_be16(pwfd_info->wfd_device_type |
823 WFD_DEVINFO_WSD |
824 WFD_DEVINFO_HDCP_SUPPORT,
825 wfdie + wfdielen);
805 } 826 }
806 827
807 } 828 }
@@ -811,13 +832,13 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
811 /* Value2: */ 832 /* Value2: */
812 /* Session Management Control Port */ 833 /* Session Management Control Port */
813 /* Default TCP port for RTSP messages is 554 */ 834 /* Default TCP port for RTSP messages is 554 */
814 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 835 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
815 wfdielen += 2; 836 wfdielen += 2;
816 837
817 /* Value3: */ 838 /* Value3: */
818 /* WFD Device Maximum Throughput */ 839 /* WFD Device Maximum Throughput */
819 /* 300Mbps is the maximum throughput */ 840 /* 300Mbps is the maximum throughput */
820 RTW_PUT_BE16(wfdie + wfdielen, 300); 841 put_unaligned_be16(300, wfdie + wfdielen);
821 wfdielen += 2; 842 wfdielen += 2;
822 843
823 /* Associated BSSID ATTR */ 844 /* Associated BSSID ATTR */
@@ -826,7 +847,7 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
826 847
827 /* Length: */ 848 /* Length: */
828 /* Note: In the WFD specification, the size of length field is 2. */ 849 /* Note: In the WFD specification, the size of length field is 2. */
829 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 850 put_unaligned_be16(0x0006, wfdie + wfdielen);
830 wfdielen += 2; 851 wfdielen += 2;
831 852
832 /* Value: */ 853 /* Value: */
@@ -848,7 +869,7 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
848 869
849 /* Length: */ 870 /* Length: */
850 /* Note: In the WFD specification, the size of length field is 2. */ 871 /* Note: In the WFD specification, the size of length field is 2. */
851 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 872 put_unaligned_be16(0x0007, wfdie + wfdielen);
852 wfdielen += 2; 873 wfdielen += 2;
853 874
854 /* Value: */ 875 /* Value: */
@@ -871,7 +892,7 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel
871 892
872 /* Length: */ 893 /* Length: */
873 /* Note: In the WFD specification, the size of length field is 2. */ 894 /* Note: In the WFD specification, the size of length field is 2. */
874 RTW_PUT_BE16(wfdie + wfdielen, 0x0000); 895 put_unaligned_be16(0x0000, wfdie + wfdielen);
875 wfdielen += 2; 896 wfdielen += 2;
876 897
877 /* Todo: to add the list of WFD device info descriptor in WFD group. */ 898 /* Todo: to add the list of WFD device info descriptor in WFD group. */
@@ -919,25 +940,27 @@ u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
919 940
920 /* Length: */ 941 /* Length: */
921 /* Note: In the WFD specification, the size of length field is 2. */ 942 /* Note: In the WFD specification, the size of length field is 2. */
922 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 943 put_unaligned_be16(0x0006, wfdie + wfdielen);
923 wfdielen += 2; 944 wfdielen += 2;
924 945
925 /* Value1: */ 946 /* Value1: */
926 /* WFD device information */ 947 /* WFD device information */
927 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 948 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
928 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 949 put_unaligned_be16(pwfd_info->wfd_device_type |
950 WFD_DEVINFO_SESSION_AVAIL |
951 WFD_DEVINFO_WSD, wfdie + wfdielen);
929 wfdielen += 2; 952 wfdielen += 2;
930 953
931 /* Value2: */ 954 /* Value2: */
932 /* Session Management Control Port */ 955 /* Session Management Control Port */
933 /* Default TCP port for RTSP messages is 554 */ 956 /* Default TCP port for RTSP messages is 554 */
934 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 957 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
935 wfdielen += 2; 958 wfdielen += 2;
936 959
937 /* Value3: */ 960 /* Value3: */
938 /* WFD Device Maximum Throughput */ 961 /* WFD Device Maximum Throughput */
939 /* 300Mbps is the maximum throughput */ 962 /* 300Mbps is the maximum throughput */
940 RTW_PUT_BE16(wfdie + wfdielen, 300); 963 put_unaligned_be16(300, wfdie + wfdielen);
941 wfdielen += 2; 964 wfdielen += 2;
942 965
943 /* Associated BSSID ATTR */ 966 /* Associated BSSID ATTR */
@@ -946,7 +969,7 @@ u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
946 969
947 /* Length: */ 970 /* Length: */
948 /* Note: In the WFD specification, the size of length field is 2. */ 971 /* Note: In the WFD specification, the size of length field is 2. */
949 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 972 put_unaligned_be16(0x0006, wfdie + wfdielen);
950 wfdielen += 2; 973 wfdielen += 2;
951 974
952 /* Value: */ 975 /* Value: */
@@ -968,7 +991,7 @@ u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
968 991
969 /* Length: */ 992 /* Length: */
970 /* Note: In the WFD specification, the size of length field is 2. */ 993 /* Note: In the WFD specification, the size of length field is 2. */
971 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 994 put_unaligned_be16(0x0007, wfdie + wfdielen);
972 wfdielen += 2; 995 wfdielen += 2;
973 996
974 /* Value: */ 997 /* Value: */
@@ -1015,25 +1038,27 @@ u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1015 1038
1016 /* Length: */ 1039 /* Length: */
1017 /* Note: In the WFD specification, the size of length field is 2. */ 1040 /* Note: In the WFD specification, the size of length field is 2. */
1018 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1041 put_unaligned_be16(0x0006, wfdie + wfdielen);
1019 wfdielen += 2; 1042 wfdielen += 2;
1020 1043
1021 /* Value1: */ 1044 /* Value1: */
1022 /* WFD device information */ 1045 /* WFD device information */
1023 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 1046 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
1024 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 1047 put_unaligned_be16(pwfd_info->wfd_device_type |
1048 WFD_DEVINFO_SESSION_AVAIL |
1049 WFD_DEVINFO_WSD, wfdie + wfdielen);
1025 wfdielen += 2; 1050 wfdielen += 2;
1026 1051
1027 /* Value2: */ 1052 /* Value2: */
1028 /* Session Management Control Port */ 1053 /* Session Management Control Port */
1029 /* Default TCP port for RTSP messages is 554 */ 1054 /* Default TCP port for RTSP messages is 554 */
1030 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1055 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1031 wfdielen += 2; 1056 wfdielen += 2;
1032 1057
1033 /* Value3: */ 1058 /* Value3: */
1034 /* WFD Device Maximum Throughput */ 1059 /* WFD Device Maximum Throughput */
1035 /* 300Mbps is the maximum throughput */ 1060 /* 300Mbps is the maximum throughput */
1036 RTW_PUT_BE16(wfdie + wfdielen, 300); 1061 put_unaligned_be16(300, wfdie + wfdielen);
1037 wfdielen += 2; 1062 wfdielen += 2;
1038 1063
1039 /* Associated BSSID ATTR */ 1064 /* Associated BSSID ATTR */
@@ -1042,7 +1067,7 @@ u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1042 1067
1043 /* Length: */ 1068 /* Length: */
1044 /* Note: In the WFD specification, the size of length field is 2. */ 1069 /* Note: In the WFD specification, the size of length field is 2. */
1045 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1070 put_unaligned_be16(0x0006, wfdie + wfdielen);
1046 wfdielen += 2; 1071 wfdielen += 2;
1047 1072
1048 /* Value: */ 1073 /* Value: */
@@ -1064,7 +1089,7 @@ u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1064 1089
1065 /* Length: */ 1090 /* Length: */
1066 /* Note: In the WFD specification, the size of length field is 2. */ 1091 /* Note: In the WFD specification, the size of length field is 2. */
1067 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1092 put_unaligned_be16(0x0007, wfdie + wfdielen);
1068 wfdielen += 2; 1093 wfdielen += 2;
1069 1094
1070 /* Value: */ 1095 /* Value: */
@@ -1111,25 +1136,27 @@ u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1111 1136
1112 /* Length: */ 1137 /* Length: */
1113 /* Note: In the WFD specification, the size of length field is 2. */ 1138 /* Note: In the WFD specification, the size of length field is 2. */
1114 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1139 put_unaligned_be16(0x0006, wfdie + wfdielen);
1115 wfdielen += 2; 1140 wfdielen += 2;
1116 1141
1117 /* Value1: */ 1142 /* Value1: */
1118 /* WFD device information */ 1143 /* WFD device information */
1119 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ 1144 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
1120 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL); 1145 put_unaligned_be16(pwfd_info->wfd_device_type |
1146 WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL,
1147 wfdie + wfdielen);
1121 wfdielen += 2; 1148 wfdielen += 2;
1122 1149
1123 /* Value2: */ 1150 /* Value2: */
1124 /* Session Management Control Port */ 1151 /* Session Management Control Port */
1125 /* Default TCP port for RTSP messages is 554 */ 1152 /* Default TCP port for RTSP messages is 554 */
1126 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1153 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1127 wfdielen += 2; 1154 wfdielen += 2;
1128 1155
1129 /* Value3: */ 1156 /* Value3: */
1130 /* WFD Device Maximum Throughput */ 1157 /* WFD Device Maximum Throughput */
1131 /* 300Mbps is the maximum throughput */ 1158 /* 300Mbps is the maximum throughput */
1132 RTW_PUT_BE16(wfdie + wfdielen, 300); 1159 put_unaligned_be16(300, wfdie + wfdielen);
1133 wfdielen += 2; 1160 wfdielen += 2;
1134 1161
1135 /* Associated BSSID ATTR */ 1162 /* Associated BSSID ATTR */
@@ -1138,7 +1165,7 @@ u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1138 1165
1139 /* Length: */ 1166 /* Length: */
1140 /* Note: In the WFD specification, the size of length field is 2. */ 1167 /* Note: In the WFD specification, the size of length field is 2. */
1141 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1168 put_unaligned_be16(0x0006, wfdie + wfdielen);
1142 wfdielen += 2; 1169 wfdielen += 2;
1143 1170
1144 /* Value: */ 1171 /* Value: */
@@ -1160,7 +1187,7 @@ u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1160 1187
1161 /* Length: */ 1188 /* Length: */
1162 /* Note: In the WFD specification, the size of length field is 2. */ 1189 /* Note: In the WFD specification, the size of length field is 2. */
1163 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1190 put_unaligned_be16(0x0007, wfdie + wfdielen);
1164 wfdielen += 2; 1191 wfdielen += 2;
1165 1192
1166 /* Value: */ 1193 /* Value: */
@@ -1207,25 +1234,27 @@ u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1207 1234
1208 /* Length: */ 1235 /* Length: */
1209 /* Note: In the WFD specification, the size of length field is 2. */ 1236 /* Note: In the WFD specification, the size of length field is 2. */
1210 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1237 put_unaligned_be16(0x0006, wfdie + wfdielen);
1211 wfdielen += 2; 1238 wfdielen += 2;
1212 1239
1213 /* Value1: */ 1240 /* Value1: */
1214 /* WFD device information */ 1241 /* WFD device information */
1215 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ 1242 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
1216 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL); 1243 put_unaligned_be16(pwfd_info->wfd_device_type |
1244 WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL,
1245 wfdie + wfdielen);
1217 wfdielen += 2; 1246 wfdielen += 2;
1218 1247
1219 /* Value2: */ 1248 /* Value2: */
1220 /* Session Management Control Port */ 1249 /* Session Management Control Port */
1221 /* Default TCP port for RTSP messages is 554 */ 1250 /* Default TCP port for RTSP messages is 554 */
1222 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1251 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1223 wfdielen += 2; 1252 wfdielen += 2;
1224 1253
1225 /* Value3: */ 1254 /* Value3: */
1226 /* WFD Device Maximum Throughput */ 1255 /* WFD Device Maximum Throughput */
1227 /* 300Mbps is the maximum throughput */ 1256 /* 300Mbps is the maximum throughput */
1228 RTW_PUT_BE16(wfdie + wfdielen, 300); 1257 put_unaligned_be16(300, wfdie + wfdielen);
1229 wfdielen += 2; 1258 wfdielen += 2;
1230 1259
1231 /* Associated BSSID ATTR */ 1260 /* Associated BSSID ATTR */
@@ -1234,7 +1263,7 @@ u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1234 1263
1235 /* Length: */ 1264 /* Length: */
1236 /* Note: In the WFD specification, the size of length field is 2. */ 1265 /* Note: In the WFD specification, the size of length field is 2. */
1237 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1266 put_unaligned_be16(0x0006, wfdie + wfdielen);
1238 wfdielen += 2; 1267 wfdielen += 2;
1239 1268
1240 /* Value: */ 1269 /* Value: */
@@ -1256,7 +1285,7 @@ u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1256 1285
1257 /* Length: */ 1286 /* Length: */
1258 /* Note: In the WFD specification, the size of length field is 2. */ 1287 /* Note: In the WFD specification, the size of length field is 2. */
1259 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1288 put_unaligned_be16(0x0007, wfdie + wfdielen);
1260 wfdielen += 2; 1289 wfdielen += 2;
1261 1290
1262 /* Value: */ 1291 /* Value: */
@@ -1303,25 +1332,26 @@ u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1303 1332
1304 /* Length: */ 1333 /* Length: */
1305 /* Note: In the WFD specification, the size of length field is 2. */ 1334 /* Note: In the WFD specification, the size of length field is 2. */
1306 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1335 put_unaligned_be16(0x0006, wfdie + wfdielen);
1307 wfdielen += 2; 1336 wfdielen += 2;
1308 1337
1309 /* Value1: */ 1338 /* Value1: */
1310 /* WFD device information */ 1339 /* WFD device information */
1311 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ 1340 /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */
1312 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL); 1341 put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD |
1342 WFD_DEVINFO_SESSION_AVAIL, wfdie + wfdielen);
1313 wfdielen += 2; 1343 wfdielen += 2;
1314 1344
1315 /* Value2: */ 1345 /* Value2: */
1316 /* Session Management Control Port */ 1346 /* Session Management Control Port */
1317 /* Default TCP port for RTSP messages is 554 */ 1347 /* Default TCP port for RTSP messages is 554 */
1318 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1348 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1319 wfdielen += 2; 1349 wfdielen += 2;
1320 1350
1321 /* Value3: */ 1351 /* Value3: */
1322 /* WFD Device Maximum Throughput */ 1352 /* WFD Device Maximum Throughput */
1323 /* 300Mbps is the maximum throughput */ 1353 /* 300Mbps is the maximum throughput */
1324 RTW_PUT_BE16(wfdie + wfdielen, 300); 1354 put_unaligned_be16(300, wfdie + wfdielen);
1325 wfdielen += 2; 1355 wfdielen += 2;
1326 1356
1327 /* Associated BSSID ATTR */ 1357 /* Associated BSSID ATTR */
@@ -1330,7 +1360,7 @@ u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1330 1360
1331 /* Length: */ 1361 /* Length: */
1332 /* Note: In the WFD specification, the size of length field is 2. */ 1362 /* Note: In the WFD specification, the size of length field is 2. */
1333 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1363 put_unaligned_be16(0x0006, wfdie + wfdielen);
1334 wfdielen += 2; 1364 wfdielen += 2;
1335 1365
1336 /* Value: */ 1366 /* Value: */
@@ -1352,7 +1382,7 @@ u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1352 1382
1353 /* Length: */ 1383 /* Length: */
1354 /* Note: In the WFD specification, the size of length field is 2. */ 1384 /* Note: In the WFD specification, the size of length field is 2. */
1355 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1385 put_unaligned_be16(0x0007, wfdie + wfdielen);
1356 wfdielen += 2; 1386 wfdielen += 2;
1357 1387
1358 /* Value: */ 1388 /* Value: */
@@ -1399,25 +1429,27 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1399 1429
1400 /* Length: */ 1430 /* Length: */
1401 /* Note: In the WFD specification, the size of length field is 2. */ 1431 /* Note: In the WFD specification, the size of length field is 2. */
1402 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1432 put_unaligned_be16(0x0006, wfdie + wfdielen);
1403 wfdielen += 2; 1433 wfdielen += 2;
1404 1434
1405 /* Value1: */ 1435 /* Value1: */
1406 /* WFD device information */ 1436 /* WFD device information */
1407 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 1437 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
1408 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 1438 put_unaligned_be16(pwfd_info->wfd_device_type |
1439 WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
1440 wfdie + wfdielen);
1409 wfdielen += 2; 1441 wfdielen += 2;
1410 1442
1411 /* Value2: */ 1443 /* Value2: */
1412 /* Session Management Control Port */ 1444 /* Session Management Control Port */
1413 /* Default TCP port for RTSP messages is 554 */ 1445 /* Default TCP port for RTSP messages is 554 */
1414 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1446 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1415 wfdielen += 2; 1447 wfdielen += 2;
1416 1448
1417 /* Value3: */ 1449 /* Value3: */
1418 /* WFD Device Maximum Throughput */ 1450 /* WFD Device Maximum Throughput */
1419 /* 300Mbps is the maximum throughput */ 1451 /* 300Mbps is the maximum throughput */
1420 RTW_PUT_BE16(wfdie + wfdielen, 300); 1452 put_unaligned_be16(300, wfdie + wfdielen);
1421 wfdielen += 2; 1453 wfdielen += 2;
1422 1454
1423 /* Associated BSSID ATTR */ 1455 /* Associated BSSID ATTR */
@@ -1426,7 +1458,7 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1426 1458
1427 /* Length: */ 1459 /* Length: */
1428 /* Note: In the WFD specification, the size of length field is 2. */ 1460 /* Note: In the WFD specification, the size of length field is 2. */
1429 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1461 put_unaligned_be16(0x0006, wfdie + wfdielen);
1430 wfdielen += 2; 1462 wfdielen += 2;
1431 1463
1432 /* Value: */ 1464 /* Value: */
@@ -1448,7 +1480,7 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1448 1480
1449 /* Length: */ 1481 /* Length: */
1450 /* Note: In the WFD specification, the size of length field is 2. */ 1482 /* Note: In the WFD specification, the size of length field is 2. */
1451 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1483 put_unaligned_be16(0x0007, wfdie + wfdielen);
1452 wfdielen += 2; 1484 wfdielen += 2;
1453 1485
1454 /* Value: */ 1486 /* Value: */
@@ -1471,7 +1503,7 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1471 1503
1472 /* Length: */ 1504 /* Length: */
1473 /* Note: In the WFD specification, the size of length field is 2. */ 1505 /* Note: In the WFD specification, the size of length field is 2. */
1474 RTW_PUT_BE16(wfdie + wfdielen, 0x0000); 1506 put_unaligned_be16(0x0000, wfdie + wfdielen);
1475 wfdielen += 2; 1507 wfdielen += 2;
1476 1508
1477 /* Todo: to add the list of WFD device info descriptor in WFD group. */ 1509 /* Todo: to add the list of WFD device info descriptor in WFD group. */
@@ -1510,25 +1542,27 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1510 1542
1511 /* Length: */ 1543 /* Length: */
1512 /* Note: In the WFD specification, the size of length field is 2. */ 1544 /* Note: In the WFD specification, the size of length field is 2. */
1513 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1545 put_unaligned_be16(0x0006, wfdie + wfdielen);
1514 wfdielen += 2; 1546 wfdielen += 2;
1515 1547
1516 /* Value1: */ 1548 /* Value1: */
1517 /* WFD device information */ 1549 /* WFD device information */
1518 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 1550 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
1519 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 1551 put_unaligned_be16(pwfd_info->wfd_device_type |
1552 WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
1553 wfdie + wfdielen);
1520 wfdielen += 2; 1554 wfdielen += 2;
1521 1555
1522 /* Value2: */ 1556 /* Value2: */
1523 /* Session Management Control Port */ 1557 /* Session Management Control Port */
1524 /* Default TCP port for RTSP messages is 554 */ 1558 /* Default TCP port for RTSP messages is 554 */
1525 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1559 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1526 wfdielen += 2; 1560 wfdielen += 2;
1527 1561
1528 /* Value3: */ 1562 /* Value3: */
1529 /* WFD Device Maximum Throughput */ 1563 /* WFD Device Maximum Throughput */
1530 /* 300Mbps is the maximum throughput */ 1564 /* 300Mbps is the maximum throughput */
1531 RTW_PUT_BE16(wfdie + wfdielen, 300); 1565 put_unaligned_be16(300, wfdie + wfdielen);
1532 wfdielen += 2; 1566 wfdielen += 2;
1533 1567
1534 /* Associated BSSID ATTR */ 1568 /* Associated BSSID ATTR */
@@ -1537,7 +1571,7 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1537 1571
1538 /* Length: */ 1572 /* Length: */
1539 /* Note: In the WFD specification, the size of length field is 2. */ 1573 /* Note: In the WFD specification, the size of length field is 2. */
1540 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1574 put_unaligned_be16(0x0006, wfdie + wfdielen);
1541 wfdielen += 2; 1575 wfdielen += 2;
1542 1576
1543 /* Value: */ 1577 /* Value: */
@@ -1559,7 +1593,7 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1559 1593
1560 /* Length: */ 1594 /* Length: */
1561 /* Note: In the WFD specification, the size of length field is 2. */ 1595 /* Note: In the WFD specification, the size of length field is 2. */
1562 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1596 put_unaligned_be16(0x0007, wfdie + wfdielen);
1563 wfdielen += 2; 1597 wfdielen += 2;
1564 1598
1565 /* Value: */ 1599 /* Value: */
@@ -1582,7 +1616,7 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1582 1616
1583 /* Length: */ 1617 /* Length: */
1584 /* Note: In the WFD specification, the size of length field is 2. */ 1618 /* Note: In the WFD specification, the size of length field is 2. */
1585 RTW_PUT_BE16(wfdie + wfdielen, 0x0000); 1619 put_unaligned_be16(0x0000, wfdie + wfdielen);
1586 wfdielen += 2; 1620 wfdielen += 2;
1587 1621
1588 /* Todo: to add the list of WFD device info descriptor in WFD group. */ 1622 /* Todo: to add the list of WFD device info descriptor in WFD group. */
@@ -1621,25 +1655,27 @@ u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1621 1655
1622 /* Length: */ 1656 /* Length: */
1623 /* Note: In the WFD specification, the size of length field is 2. */ 1657 /* Note: In the WFD specification, the size of length field is 2. */
1624 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1658 put_unaligned_be16(0x0006, wfdie + wfdielen);
1625 wfdielen += 2; 1659 wfdielen += 2;
1626 1660
1627 /* Value1: */ 1661 /* Value1: */
1628 /* WFD device information */ 1662 /* WFD device information */
1629 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 1663 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
1630 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 1664 put_unaligned_be16(pwfd_info->wfd_device_type |
1665 WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
1666 wfdie + wfdielen);
1631 wfdielen += 2; 1667 wfdielen += 2;
1632 1668
1633 /* Value2: */ 1669 /* Value2: */
1634 /* Session Management Control Port */ 1670 /* Session Management Control Port */
1635 /* Default TCP port for RTSP messages is 554 */ 1671 /* Default TCP port for RTSP messages is 554 */
1636 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1672 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1637 wfdielen += 2; 1673 wfdielen += 2;
1638 1674
1639 /* Value3: */ 1675 /* Value3: */
1640 /* WFD Device Maximum Throughput */ 1676 /* WFD Device Maximum Throughput */
1641 /* 300Mbps is the maximum throughput */ 1677 /* 300Mbps is the maximum throughput */
1642 RTW_PUT_BE16(wfdie + wfdielen, 300); 1678 put_unaligned_be16(300, wfdie + wfdielen);
1643 wfdielen += 2; 1679 wfdielen += 2;
1644 1680
1645 /* Associated BSSID ATTR */ 1681 /* Associated BSSID ATTR */
@@ -1648,7 +1684,7 @@ u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1648 1684
1649 /* Length: */ 1685 /* Length: */
1650 /* Note: In the WFD specification, the size of length field is 2. */ 1686 /* Note: In the WFD specification, the size of length field is 2. */
1651 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1687 put_unaligned_be16(0x0006, wfdie + wfdielen);
1652 wfdielen += 2; 1688 wfdielen += 2;
1653 1689
1654 /* Value: */ 1690 /* Value: */
@@ -1670,7 +1706,7 @@ u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1670 1706
1671 /* Length: */ 1707 /* Length: */
1672 /* Note: In the WFD specification, the size of length field is 2. */ 1708 /* Note: In the WFD specification, the size of length field is 2. */
1673 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1709 put_unaligned_be16(0x0007, wfdie + wfdielen);
1674 wfdielen += 2; 1710 wfdielen += 2;
1675 1711
1676 /* Value: */ 1712 /* Value: */
@@ -1717,25 +1753,27 @@ u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1717 1753
1718 /* Length: */ 1754 /* Length: */
1719 /* Note: In the WFD specification, the size of length field is 2. */ 1755 /* Note: In the WFD specification, the size of length field is 2. */
1720 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1756 put_unaligned_be16(0x0006, wfdie + wfdielen);
1721 wfdielen += 2; 1757 wfdielen += 2;
1722 1758
1723 /* Value1: */ 1759 /* Value1: */
1724 /* WFD device information */ 1760 /* WFD device information */
1725 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ 1761 /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */
1726 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD); 1762 put_unaligned_be16(pwfd_info->wfd_device_type |
1763 WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD,
1764 wfdie + wfdielen);
1727 wfdielen += 2; 1765 wfdielen += 2;
1728 1766
1729 /* Value2: */ 1767 /* Value2: */
1730 /* Session Management Control Port */ 1768 /* Session Management Control Port */
1731 /* Default TCP port for RTSP messages is 554 */ 1769 /* Default TCP port for RTSP messages is 554 */
1732 RTW_PUT_BE16(wfdie + wfdielen, pwfd_info->rtsp_ctrlport); 1770 put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen);
1733 wfdielen += 2; 1771 wfdielen += 2;
1734 1772
1735 /* Value3: */ 1773 /* Value3: */
1736 /* WFD Device Maximum Throughput */ 1774 /* WFD Device Maximum Throughput */
1737 /* 300Mbps is the maximum throughput */ 1775 /* 300Mbps is the maximum throughput */
1738 RTW_PUT_BE16(wfdie + wfdielen, 300); 1776 put_unaligned_be16(300, wfdie + wfdielen);
1739 wfdielen += 2; 1777 wfdielen += 2;
1740 1778
1741 /* Associated BSSID ATTR */ 1779 /* Associated BSSID ATTR */
@@ -1744,7 +1782,7 @@ u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1744 1782
1745 /* Length: */ 1783 /* Length: */
1746 /* Note: In the WFD specification, the size of length field is 2. */ 1784 /* Note: In the WFD specification, the size of length field is 2. */
1747 RTW_PUT_BE16(wfdie + wfdielen, 0x0006); 1785 put_unaligned_be16(0x0006, wfdie + wfdielen);
1748 wfdielen += 2; 1786 wfdielen += 2;
1749 1787
1750 /* Value: */ 1788 /* Value: */
@@ -1766,7 +1804,7 @@ u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf)
1766 1804
1767 /* Length: */ 1805 /* Length: */
1768 /* Note: In the WFD specification, the size of length field is 2. */ 1806 /* Note: In the WFD specification, the size of length field is 2. */
1769 RTW_PUT_BE16(wfdie + wfdielen, 0x0007); 1807 put_unaligned_be16(0x0007, wfdie + wfdielen);
1770 wfdielen += 2; 1808 wfdielen += 2;
1771 1809
1772 /* Value: */ 1810 /* Value: */
@@ -1814,7 +1852,7 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
1814 1852
1815 /* Length: */ 1853 /* Length: */
1816 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ 1854 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
1817 RTW_PUT_LE16(p2pie + p2pielen, 0x0002); 1855 put_unaligned_le16(0x0002, p2pie + p2pielen);
1818 p2pielen += 2; 1856 p2pielen += 2;
1819 1857
1820 /* Value: */ 1858 /* Value: */
@@ -1846,18 +1884,18 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
1846 1884
1847 /* Length: */ 1885 /* Length: */
1848 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ 1886 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */
1849 RTW_PUT_LE16(p2pie + p2pielen, 0x0004); 1887 put_unaligned_le16(0x0004, p2pie + p2pielen);
1850 p2pielen += 2; 1888 p2pielen += 2;
1851 1889
1852 /* Value: */ 1890 /* Value: */
1853 /* Availability Period */ 1891 /* Availability Period */
1854 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ 1892 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
1855 RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); 1893 put_unaligned_le16(0xFFFF, p2pie + p2pielen);
1856 p2pielen += 2; 1894 p2pielen += 2;
1857 1895
1858 /* Availability Interval */ 1896 /* Availability Interval */
1859 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ 1897 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */
1860 RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); 1898 put_unaligned_le16(0xFFFF, p2pie + p2pielen);
1861 p2pielen += 2; 1899 p2pielen += 2;
1862 1900
1863 /* Notice of Absence ATTR */ 1901 /* Notice of Absence ATTR */
@@ -1877,7 +1915,7 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
1877 /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ 1915 /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
1878 /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ 1916 /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
1879 /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ 1917 /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
1880 RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); 1918 put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen);
1881 p2pielen += 2; 1919 p2pielen += 2;
1882 1920
1883 /* Value: */ 1921 /* Value: */
@@ -1888,23 +1926,23 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
1888 /* Config Method */ 1926 /* Config Method */
1889 /* This field should be big endian. Noted by P2P specification. */ 1927 /* This field should be big endian. Noted by P2P specification. */
1890 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ 1928 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */
1891 RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->supported_wps_cm); 1929 put_unaligned_be16(pwdinfo->supported_wps_cm, p2pie + p2pielen);
1892 p2pielen += 2; 1930 p2pielen += 2;
1893 1931
1894 /* Primary Device Type */ 1932 /* Primary Device Type */
1895 /* Category ID */ 1933 /* Category ID */
1896 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ 1934 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
1897 RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); 1935 put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen);
1898 p2pielen += 2; 1936 p2pielen += 2;
1899 1937
1900 /* OUI */ 1938 /* OUI */
1901 /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ 1939 /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
1902 RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); 1940 put_unaligned_be32(WPSOUI, p2pie + p2pielen);
1903 p2pielen += 4; 1941 p2pielen += 4;
1904 1942
1905 /* Sub Category ID */ 1943 /* Sub Category ID */
1906 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ 1944 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
1907 RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); 1945 put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen);
1908 p2pielen += 2; 1946 p2pielen += 2;
1909 1947
1910 /* Number of Secondary Device Types */ 1948 /* Number of Secondary Device Types */
@@ -1913,12 +1951,12 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf)
1913 /* Device Name */ 1951 /* Device Name */
1914 /* Type: */ 1952 /* Type: */
1915 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ 1953 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
1916 RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); 1954 put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen);
1917 p2pielen += 2; 1955 p2pielen += 2;
1918 1956
1919 /* Length: */ 1957 /* Length: */
1920 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ 1958 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
1921 RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); 1959 put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen);
1922 p2pielen += 2; 1960 p2pielen += 2;
1923 1961
1924 /* Value: */ 1962 /* Value: */
@@ -1963,7 +2001,7 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
1963 2001
1964 /* Length: */ 2002 /* Length: */
1965 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ 2003 /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */
1966 RTW_PUT_LE16(p2pie + p2pielen, 0x0002); 2004 put_unaligned_le16(0x0002, p2pie + p2pielen);
1967 p2pielen += 2; 2005 p2pielen += 2;
1968 2006
1969 /* Value: */ 2007 /* Value: */
@@ -1984,7 +2022,7 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
1984 /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ 2022 /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */
1985 /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ 2023 /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */
1986 /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ 2024 /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */
1987 RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); 2025 put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen);
1988 p2pielen += 2; 2026 p2pielen += 2;
1989 2027
1990 /* Value: */ 2028 /* Value: */
@@ -1997,12 +2035,12 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
1997 if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) 2035 if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC)
1998 { 2036 {
1999 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ 2037 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */
2000 RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_PBC); 2038 put_unaligned_be16(WPS_CONFIG_METHOD_PBC, p2pie + p2pielen);
2001 } 2039 }
2002 else 2040 else
2003 { 2041 {
2004 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ 2042 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */
2005 RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_DISPLAY); 2043 put_unaligned_be16(WPS_CONFIG_METHOD_DISPLAY, p2pie + p2pielen);
2006 } 2044 }
2007 2045
2008 p2pielen += 2; 2046 p2pielen += 2;
@@ -2010,17 +2048,17 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
2010 /* Primary Device Type */ 2048 /* Primary Device Type */
2011 /* Category ID */ 2049 /* Category ID */
2012 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ 2050 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */
2013 RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); 2051 put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen);
2014 p2pielen += 2; 2052 p2pielen += 2;
2015 2053
2016 /* OUI */ 2054 /* OUI */
2017 /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ 2055 /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */
2018 RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); 2056 put_unaligned_be32(WPSOUI, p2pie + p2pielen);
2019 p2pielen += 4; 2057 p2pielen += 4;
2020 2058
2021 /* Sub Category ID */ 2059 /* Sub Category ID */
2022 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ 2060 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */
2023 RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); 2061 put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen);
2024 p2pielen += 2; 2062 p2pielen += 2;
2025 2063
2026 /* Number of Secondary Device Types */ 2064 /* Number of Secondary Device Types */
@@ -2029,12 +2067,12 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
2029 /* Device Name */ 2067 /* Device Name */
2030 /* Type: */ 2068 /* Type: */
2031 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ 2069 /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */
2032 RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); 2070 put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen);
2033 p2pielen += 2; 2071 p2pielen += 2;
2034 2072
2035 /* Length: */ 2073 /* Length: */
2036 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ 2074 /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */
2037 RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); 2075 put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen);
2038 p2pielen += 2; 2076 p2pielen += 2;
2039 2077
2040 /* Value: */ 2078 /* Value: */
@@ -2052,7 +2090,7 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf,
2052 2090
2053 /* Length: */ 2091 /* Length: */
2054 /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ 2092 /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */
2055 RTW_PUT_LE16(p2pie + p2pielen, ETH_ALEN + ussidlen); 2093 put_unaligned_le16(ETH_ALEN + ussidlen, p2pie + p2pielen);
2056 p2pielen += 2; 2094 p2pielen += 2;
2057 2095
2058 /* Value: */ 2096 /* Value: */
@@ -2685,7 +2723,7 @@ u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pfra
2685 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); 2723 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
2686 if (attr_contentlen) 2724 if (attr_contentlen)
2687 { 2725 {
2688 pwdinfo->wfd_info->peer_rtsp_ctrlport = RTW_GET_BE16(attr_content + 2); 2726 pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
2689 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); 2727 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
2690 } 2728 }
2691 } 2729 }
@@ -2926,7 +2964,7 @@ u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pfr
2926 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); 2964 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
2927 if (attr_contentlen) 2965 if (attr_contentlen)
2928 { 2966 {
2929 pwdinfo->wfd_info->peer_rtsp_ctrlport = RTW_GET_BE16(attr_content + 2); 2967 pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
2930 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); 2968 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
2931 } 2969 }
2932 } 2970 }
@@ -3859,7 +3897,7 @@ void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role)
3859 3897
3860 rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); 3898 rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE);
3861 3899
3862 pwdinfo->listen_dwell = (u8) ((rtw_get_current_time() % 3) + 1); 3900 pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1);
3863 /* DBG_8723A("[%s] listen_dwell time is %d00ms\n", __func__, pwdinfo->listen_dwell); */ 3901 /* DBG_8723A("[%s] listen_dwell time is %d00ms\n", __func__, pwdinfo->listen_dwell); */
3864 3902
3865 memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); 3903 memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info));
diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
index 354873ca344e..8ddd67f194ba 100644
--- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
@@ -108,13 +108,11 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter)
108 struct rtw_adapter *buddy = adapter->pbuddy_adapter; 108 struct rtw_adapter *buddy = adapter->pbuddy_adapter;
109 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 109 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
110 struct xmit_priv *pxmit_priv = &adapter->xmitpriv; 110 struct xmit_priv *pxmit_priv = &adapter->xmitpriv;
111#ifdef CONFIG_8723AU_P2P
112 struct wifidirect_info *pwdinfo = &adapter->wdinfo; 111 struct wifidirect_info *pwdinfo = &adapter->wdinfo;
113#endif
114 112
115 bool ret = false; 113 bool ret = false;
116 114
117 if (adapter->pwrctrlpriv.ips_deny_time >= rtw_get_current_time()) 115 if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies))
118 goto exit; 116 goto exit;
119 117
120 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) 118 if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR)
@@ -129,9 +127,7 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter)
129 /* consider buddy, if exist */ 127 /* consider buddy, if exist */
130 if (buddy) { 128 if (buddy) {
131 struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv; 129 struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv;
132#ifdef CONFIG_8723AU_P2P
133 struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; 130 struct wifidirect_info *b_pwdinfo = &buddy->wdinfo;
134#endif
135 131
136 if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) 132 if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR)
137 || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) 133 || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS)
@@ -386,11 +382,13 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u
386 */ 382 */
387s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) 383s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms)
388{ 384{
389 u32 start_time; 385 unsigned long start_time, end_time;
390 u8 bAwake = false; 386 u8 bAwake = false;
391 s32 err = 0; 387 s32 err = 0;
392 388
393 start_time = rtw_get_current_time(); 389 start_time = jiffies;
390 end_time = start_time + msecs_to_jiffies(delay_ms);
391
394 while (1) 392 while (1)
395 { 393 {
396 rtw23a_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); 394 rtw23a_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake);
@@ -404,8 +402,7 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms)
404 break; 402 break;
405 } 403 }
406 404
407 if (rtw_get_passing_time_ms23a(start_time) > delay_ms) 405 if (time_after(jiffies, end_time)) {
408 {
409 err = -1; 406 err = -1;
410 DBG_8723A("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); 407 DBG_8723A("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms);
411 break; 408 break;
@@ -539,7 +536,7 @@ u8 rtw_interface_ps_func23a(struct rtw_adapter *padapter, enum hal_intf_ps_func
539inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms) 536inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms)
540{ 537{
541 struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; 538 struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
542 pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime23a(ms); 539 pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms);
543} 540}
544 541
545/* 542/*
@@ -554,14 +551,18 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
554 struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; 551 struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
555 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 552 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
556 int ret = _SUCCESS; 553 int ret = _SUCCESS;
557 u32 start = rtw_get_current_time(); 554 unsigned long start = jiffies;
555 unsigned long new_deny_time;
556
557 new_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms);
558 558
559 if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime23a(ips_deffer_ms)) 559 if (time_before(pwrpriv->ips_deny_time, new_deny_time))
560 pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime23a(ips_deffer_ms); 560 pwrpriv->ips_deny_time = new_deny_time;
561 561
562 if (pwrpriv->ps_processing) { 562 if (pwrpriv->ps_processing) {
563 DBG_8723A("%s wait ps_processing...\n", __func__); 563 DBG_8723A("%s wait ps_processing...\n", __func__);
564 while (pwrpriv->ps_processing && rtw_get_passing_time_ms23a(start) <= 3000) 564 while (pwrpriv->ps_processing &&
565 jiffies_to_msecs(jiffies - start) <= 3000)
565 msleep(10); 566 msleep(10);
566 if (pwrpriv->ps_processing) 567 if (pwrpriv->ps_processing)
567 DBG_8723A("%s wait ps_processing timeout\n", __func__); 568 DBG_8723A("%s wait ps_processing timeout\n", __func__);
@@ -571,7 +572,8 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
571 572
572 if (rtw_hal_sreset_inprogress(padapter)) { 573 if (rtw_hal_sreset_inprogress(padapter)) {
573 DBG_8723A("%s wait sreset_inprogress...\n", __func__); 574 DBG_8723A("%s wait sreset_inprogress...\n", __func__);
574 while (rtw_hal_sreset_inprogress(padapter) && rtw_get_passing_time_ms23a(start) <= 4000) 575 while (rtw_hal_sreset_inprogress(padapter) &&
576 jiffies_to_msecs(jiffies - start) <= 4000)
575 msleep(10); 577 msleep(10);
576 if (rtw_hal_sreset_inprogress(padapter)) 578 if (rtw_hal_sreset_inprogress(padapter))
577 DBG_8723A("%s wait sreset_inprogress timeout\n", __func__); 579 DBG_8723A("%s wait sreset_inprogress timeout\n", __func__);
@@ -582,7 +584,7 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
582 if (pwrpriv->bInternalAutoSuspend == false && pwrpriv->bInSuspend) { 584 if (pwrpriv->bInternalAutoSuspend == false && pwrpriv->bInSuspend) {
583 DBG_8723A("%s wait bInSuspend...\n", __func__); 585 DBG_8723A("%s wait bInSuspend...\n", __func__);
584 while (pwrpriv->bInSuspend && 586 while (pwrpriv->bInSuspend &&
585 (rtw_get_passing_time_ms23a(start) <= 3000)) { 587 (jiffies_to_msecs(jiffies - start) <= 3000)) {
586 msleep(10); 588 msleep(10);
587 } 589 }
588 if (pwrpriv->bInSuspend) 590 if (pwrpriv->bInSuspend)
@@ -630,8 +632,9 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch
630 } 632 }
631 633
632exit: 634exit:
633 if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime23a(ips_deffer_ms)) 635 new_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms);
634 pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime23a(ips_deffer_ms); 636 if (time_before(pwrpriv->ips_deny_time, new_deny_time))
637 pwrpriv->ips_deny_time = new_deny_time;
635 return ret; 638 return ret;
636} 639}
637 640
diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c
index 0d457144fde7..fd43e71bf6d6 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -202,7 +202,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
202 arcfour_encrypt(&mycontext, payload + length, crc, 4); 202 arcfour_encrypt(&mycontext, payload + length, crc, 4);
203 203
204 pframe += pxmitpriv->frag_len; 204 pframe += pxmitpriv->frag_len;
205 pframe = (u8 *)RND4((unsigned long)(pframe)); 205 pframe = PTR_ALIGN(pframe, 4);
206 } 206 }
207 } 207 }
208 208
@@ -225,7 +225,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
225 pframe = skb->data; 225 pframe = skb->data;
226 226
227 /* start to decrypt recvframe */ 227 /* start to decrypt recvframe */
228 if ((prxattrib->encrypt =! _WEP40_) && (prxattrib->encrypt != _WEP104_)) 228 if ((prxattrib->encrypt != _WEP40_) && (prxattrib->encrypt != _WEP104_))
229 return; 229 return;
230 230
231 iv = pframe + prxattrib->hdrlen; 231 iv = pframe + prxattrib->hdrlen;
@@ -699,8 +699,7 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
699 arcfour_encrypt(&mycontext, payload+length, crc, 4); 699 arcfour_encrypt(&mycontext, payload+length, crc, 4);
700 700
701 pframe+= pxmitpriv->frag_len; 701 pframe+= pxmitpriv->frag_len;
702 pframe = (u8 *)RND4((unsigned long)(pframe)); 702 pframe = PTR_ALIGN(pframe, 4);
703
704 } 703 }
705 } 704 }
706 705
@@ -1371,7 +1370,7 @@ u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitfra
1371 1370
1372 aes_cipher(prwskey, pattrib->hdrlen, pframe, length); 1371 aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
1373 pframe += pxmitpriv->frag_len; 1372 pframe += pxmitpriv->frag_len;
1374 pframe = (u8*)RND4((unsigned long)pframe); 1373 pframe = PTR_ALIGN(pframe, 4);
1375 } 1374 }
1376 } 1375 }
1377out: 1376out:
@@ -1599,7 +1598,7 @@ u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvfra
1599 1598
1600 pframe = skb->data; 1599 pframe = skb->data;
1601 /* 4 start to encrypt each fragment */ 1600 /* 4 start to encrypt each fragment */
1602 if (!prxattrib->encrypt != _AES_) 1601 if (prxattrib->encrypt != _AES_)
1603 return _FAIL; 1602 return _FAIL;
1604 1603
1605 stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]); 1604 stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]);
diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c
index 8d1a6fe168ac..4f7459203390 100644
--- a/drivers/staging/rtl8723au/core/rtw_sreset.c
+++ b/drivers/staging/rtl8723au/core/rtw_sreset.c
@@ -165,9 +165,11 @@ static void sreset_restore_network_status(struct rtw_adapter *padapter)
165 if (check_fwstate(mlmepriv, WIFI_STATION_STATE)) { 165 if (check_fwstate(mlmepriv, WIFI_STATION_STATE)) {
166 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); 166 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
167 sreset_restore_network_station(padapter); 167 sreset_restore_network_station(padapter);
168#ifdef CONFIG_8723AU_AP_MODE
168 } else if (check_fwstate(mlmepriv, WIFI_AP_STATE)) { 169 } else if (check_fwstate(mlmepriv, WIFI_AP_STATE)) {
169 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); 170 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
170 rtw_ap_restore_network(padapter); 171 rtw_ap_restore_network(padapter);
172#endif
171 } else if (check_fwstate(mlmepriv, WIFI_ADHOC_STATE)) { 173 } else if (check_fwstate(mlmepriv, WIFI_ADHOC_STATE)) {
172 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); 174 DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv));
173 } else { 175 } else {
diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
index 76d2f240656e..0dfcfbce3b52 100644
--- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
@@ -581,7 +581,7 @@ int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies *
581 DBG_8723A("[%s] Found WFD IE\n", __func__); 581 DBG_8723A("[%s] Found WFD IE\n", __func__);
582 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); 582 rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen);
583 if (attr_contentlen) { 583 if (attr_contentlen) {
584 pwdinfo->wfd_info->peer_rtsp_ctrlport = RTW_GET_BE16(attr_content + 2); 584 pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2);
585 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); 585 DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport);
586 return true; 586 return true;
587 } 587 }
diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index a1abba053944..0f10cfa10d39 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -785,7 +785,7 @@ static s32 xmitframe_addmic(struct rtw_adapter *padapter,
785 785
786 for (curfragnum = 0; curfragnum < pattrib->nr_frags; 786 for (curfragnum = 0; curfragnum < pattrib->nr_frags;
787 curfragnum++) { 787 curfragnum++) {
788 payload = (u8 *)RND4((unsigned long)payload); 788 payload = PTR_ALIGN(payload, 4);
789 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, 789 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
790 ("=== curfragnum =%d, pframe = 0x%.2x, " 790 ("=== curfragnum =%d, pframe = 0x%.2x, "
791 "0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x" 791 "0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x"
@@ -1124,7 +1124,6 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
1124 struct xmit_priv *pxmitpriv = &padapter->xmitpriv; 1124 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
1125 struct pkt_attrib *pattrib = &pxmitframe->attrib; 1125 struct pkt_attrib *pattrib = &pxmitframe->attrib;
1126 s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; 1126 s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
1127 unsigned long addr;
1128 u8 *pframe, *mem_start; 1127 u8 *pframe, *mem_start;
1129 u8 hw_hdr_offset; 1128 u8 hw_hdr_offset;
1130 u8 *pbuf_start; 1129 u8 *pbuf_start;
@@ -1261,9 +1260,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt,
1261 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); 1260 RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__));
1262 } 1261 }
1263 1262
1264 addr = (unsigned long)pframe; 1263 mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset;
1265
1266 mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset;
1267 memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); 1264 memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
1268 1265
1269 } 1266 }
diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c
index c1a5b735ecf3..de3608b4010a 100644
--- a/drivers/staging/rtl8723au/hal/hal_intf.c
+++ b/drivers/staging/rtl8723au/hal/hal_intf.c
@@ -259,7 +259,9 @@ void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level)
259 pmlmepriv = &padapter->mlmepriv; 259 pmlmepriv = &padapter->mlmepriv;
260 260
261 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { 261 if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
262#ifdef CONFIG_8723AU_AP_MODE
262 add_RATid23a(padapter, psta, rssi_level); 263 add_RATid23a(padapter, psta, rssi_level);
264#endif
263 } else { 265 } else {
264 if (padapter->HalFunc.UpdateRAMaskHandler) 266 if (padapter->HalFunc.UpdateRAMaskHandler)
265 padapter->HalFunc.UpdateRAMaskHandler(padapter, psta->mac_id, rssi_level); 267 padapter->HalFunc.UpdateRAMaskHandler(padapter, psta->mac_id, rssi_level);
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
index 2d4135f741eb..9d738d79de4b 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
@@ -4620,11 +4620,11 @@ bthci_StateConnected(struct rtw_adapter *padapter,
4620/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */ 4620/*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
4621 struct bt_30info *pBTInfo = GET_BT_INFO(padapter); 4621 struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
4622 struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt; 4622 struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt;
4623 u8 i;
4624 u16 logicHandle = 0;
4623 4625
4624 RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state], [Connected], ")); 4626 RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state], [Connected], "));
4625 switch (StateCmd) { 4627 switch (StateCmd) {
4626 u8 i;
4627 u16 logicHandle = 0;
4628 case STATE_CMD_DISCONNECT_PHY_LINK: 4628 case STATE_CMD_DISCONNECT_PHY_LINK:
4629 RTPRINT(FIOCTL, IOCTL_STATE, ("STATE_CMD_DISCONNECT_PHY_LINK\n")); 4629 RTPRINT(FIOCTL, IOCTL_STATE, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4630 4630
@@ -7076,17 +7076,17 @@ static void btdm_2AntBtInquiryPage(struct rtw_adapter *padapter)
7076static u8 btdm_HoldForBtInqPage(struct rtw_adapter *padapter) 7076static u8 btdm_HoldForBtInqPage(struct rtw_adapter *padapter)
7077{ 7077{
7078 struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); 7078 struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
7079 u32 curTime = rtw_get_current_time(); 7079 u32 curTime = jiffies;
7080 7080
7081 if (pHalData->bt_coexist.halCoex8723.bC2hBtInquiryPage) { 7081 if (pHalData->bt_coexist.halCoex8723.bC2hBtInquiryPage) {
7082 /* bt inquiry or page is started. */ 7082 /* bt inquiry or page is started. */
7083 if (pHalData->bt_coexist.halCoex8723.btInqPageStartTime == 0) { 7083 if (pHalData->bt_coexist.halCoex8723.btInqPageStartTime == 0) {
7084 pHalData->bt_coexist.halCoex8723.btInqPageStartTime = curTime; 7084 pHalData->bt_coexist.halCoex8723.btInqPageStartTime = curTime;
7085 RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT Inquiry/page is started at time : 0x%"i64fmt"x \n", 7085 RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT Inquiry/page is started at time : 0x%lx \n",
7086 pHalData->bt_coexist.halCoex8723.btInqPageStartTime)); 7086 pHalData->bt_coexist.halCoex8723.btInqPageStartTime));
7087 } 7087 }
7088 } 7088 }
7089 RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT Inquiry/page started time : 0x%"i64fmt"x, curTime : 0x%x \n", 7089 RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT Inquiry/page started time : 0x%lx, curTime : 0x%x \n",
7090 pHalData->bt_coexist.halCoex8723.btInqPageStartTime, curTime)); 7090 pHalData->bt_coexist.halCoex8723.btInqPageStartTime, curTime));
7091 7091
7092 if (pHalData->bt_coexist.halCoex8723.btInqPageStartTime) { 7092 if (pHalData->bt_coexist.halCoex8723.btInqPageStartTime) {
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index fd00ddb3c951..0982b0a4ab9b 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -388,7 +388,7 @@ s32 rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
388 rtStatus = _WriteFW(padapter, buf, fw_size); 388 rtStatus = _WriteFW(padapter, buf, fw_size);
389 389
390 if (rtStatus == _SUCCESS || 390 if (rtStatus == _SUCCESS ||
391 (rtw_get_passing_time_ms23a(fwdl_start_time) > 500 && 391 (jiffies_to_msecs(jiffies - fwdl_start_time) > 500 &&
392 writeFW_retry++ >= 3)) 392 writeFW_retry++ >= 3))
393 break; 393 break;
394 394
diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
index 3165ff5dfa73..2af2e3ee1abc 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
@@ -366,7 +366,7 @@ static s32 rtw_dump_xframe(struct rtw_adapter *padapter, struct xmit_frame *pxmi
366 366
367 mem_addr += w_sz; 367 mem_addr += w_sz;
368 368
369 mem_addr = (u8 *)RND4(((unsigned long)(mem_addr))); 369 mem_addr = PTR_ALIGN(mem_addr, 4);
370 } 370 }
371 371
372 rtw_free_xmitframe23a(pxmitpriv, pxmitframe); 372 rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
diff --git a/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h b/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h
index 4aa8cdb5fb90..1478d311683a 100644
--- a/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h
+++ b/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h
@@ -65,8 +65,6 @@ enum RF_RADIO_PATH {
65 RF_PATH_MAX /* Max RF number 90 support */ 65 RF_PATH_MAX /* Max RF number 90 support */
66}; 66};
67 67
68#define RF_PATH_MAX 3
69
70#define CHANNEL_MAX_NUMBER 14 /* 14 is the max channel number */ 68#define CHANNEL_MAX_NUMBER 14 /* 14 is the max channel number */
71#define CHANNEL_GROUP_MAX 3 /* ch1~3, ch4~9, ch10~14 total three groups */ 69#define CHANNEL_GROUP_MAX 3 /* ch1~3, ch4~9, ch10~14 total three groups */
72 70
diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h
index 58479884254a..53eecea48cec 100644
--- a/drivers/staging/rtl8723au/include/drv_types.h
+++ b/drivers/staging/rtl8723au/include/drv_types.h
@@ -258,13 +258,9 @@ struct rtw_adapter {
258 struct hostapd_priv *phostapdpriv; 258 struct hostapd_priv *phostapdpriv;
259#endif 259#endif
260 260
261#ifdef CONFIG_8723AU_P2P
262 struct cfg80211_wifidirect_info cfg80211_wdinfo; 261 struct cfg80211_wifidirect_info cfg80211_wdinfo;
263#endif /* CONFIG_8723AU_P2P */
264 u32 setband; 262 u32 setband;
265#ifdef CONFIG_8723AU_P2P
266 struct wifidirect_info wdinfo; 263 struct wifidirect_info wdinfo;
267#endif /* CONFIG_8723AU_P2P */
268 264
269#ifdef CONFIG_8723AU_P2P 265#ifdef CONFIG_8723AU_P2P
270 struct wifi_display_info wfd_info; 266 struct wifi_display_info wfd_info;
diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h
index ac4273288cca..dfedfbb48fc2 100644
--- a/drivers/staging/rtl8723au/include/odm.h
+++ b/drivers/staging/rtl8723au/include/odm.h
@@ -265,35 +265,30 @@ struct odm_rate_adapt {
265#define DM_Type_ByFW 0 265#define DM_Type_ByFW 0
266#define DM_Type_ByDriver 1 266#define DM_Type_ByDriver 1
267 267
268/* */
269/* Declare for common info */
270/* */
271/* Declare for common info */ 268/* Declare for common info */
272/* */
273#define MAX_PATH_NUM_92CS 2
274 269
275struct odm_phy_info { 270struct odm_phy_info {
276 u8 RxPWDBAll; 271 u8 RxPWDBAll;
277 u8 SignalQuality; /* in 0-100 index. */ 272 u8 SignalQuality; /* in 0-100 index. */
278 u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ 273 u8 RxMIMOSignalQuality[RF_PATH_MAX]; /* EVM */
279 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ 274 u8 RxMIMOSignalStrength[RF_PATH_MAX];/* in 0~100 index */
280 s8 RxPower; /* in dBm Translate from PWdB */ 275 s8 RxPower; /* in dBm Translate from PWdB */
281 s8 RecvSignalPower;/* Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures. */ 276 s8 RecvSignalPower;/* Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures. */
282 u8 BTRxRSSIPercentage; 277 u8 BTRxRSSIPercentage;
283 u8 SignalStrength; /* in 0-100 index. */ 278 u8 SignalStrength; /* in 0-100 index. */
284 u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ 279 u8 RxPwr[RF_PATH_MAX];/* per-path's pwdb */
285 u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ 280 u8 RxSNR[RF_PATH_MAX];/* per-path's SNR */
286}; 281};
287 282
288 283
289struct odm_phy_dbg_info { 284struct odm_phy_dbg_info {
290 /* ODM Write,debug info */ 285 /* ODM Write,debug info */
291 s8 RxSNRdB[MAX_PATH_NUM_92CS]; 286 s8 RxSNRdB[RF_PATH_MAX];
292 u64 NumQryPhyStatus; 287 u64 NumQryPhyStatus;
293 u64 NumQryPhyStatusCCK; 288 u64 NumQryPhyStatusCCK;
294 u64 NumQryPhyStatusOFDM; 289 u64 NumQryPhyStatusOFDM;
295 /* Others */ 290 /* Others */
296 s32 RxEVM[MAX_PATH_NUM_92CS]; 291 s32 RxEVM[RF_PATH_MAX];
297 292
298}; 293};
299 294
diff --git a/drivers/staging/rtl8723au/include/odm_HWConfig.h b/drivers/staging/rtl8723au/include/odm_HWConfig.h
index 057fdb012a47..147855c96ad4 100644
--- a/drivers/staging/rtl8723au/include/odm_HWConfig.h
+++ b/drivers/staging/rtl8723au/include/odm_HWConfig.h
@@ -74,21 +74,21 @@ struct phy_rx_agc_info {
74}; 74};
75 75
76struct phy_status_rpt { 76struct phy_status_rpt {
77 struct phy_rx_agc_info path_agc[2]; 77 struct phy_rx_agc_info path_agc[RF_PATH_MAX];
78 u8 ch_corr[2]; 78 u8 ch_corr[RF_PATH_MAX];
79 u8 cck_sig_qual_ofdm_pwdb_all; 79 u8 cck_sig_qual_ofdm_pwdb_all;
80 u8 cck_agc_rpt_ofdm_cfosho_a; 80 u8 cck_agc_rpt_ofdm_cfosho_a;
81 u8 cck_rpt_b_ofdm_cfosho_b; 81 u8 cck_rpt_b_ofdm_cfosho_b;
82 u8 rsvd_1;/* ch_corr_msb; */ 82 u8 rsvd_1;/* ch_corr_msb; */
83 u8 noise_power_db_msb; 83 u8 noise_power_db_msb;
84 u8 path_cfotail[2]; 84 u8 path_cfotail[RF_PATH_MAX];
85 u8 pcts_mask[2]; 85 u8 pcts_mask[RF_PATH_MAX];
86 s8 stream_rxevm[2]; 86 s8 stream_rxevm[RF_PATH_MAX];
87 u8 path_rxsnr[2]; 87 u8 path_rxsnr[RF_PATH_MAX];
88 u8 noise_power_db_lsb; 88 u8 noise_power_db_lsb;
89 u8 rsvd_2[3]; 89 u8 rsvd_2[3];
90 u8 stream_csi[2]; 90 u8 stream_csi[RF_PATH_MAX];
91 u8 stream_target_csi[2]; 91 u8 stream_target_csi[RF_PATH_MAX];
92 s8 sig_evm; 92 s8 sig_evm;
93 u8 rsvd_3; 93 u8 rsvd_3;
94 94
diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h
index cb7b5cdcbe55..039bc7285ed0 100644
--- a/drivers/staging/rtl8723au/include/osdep_service.h
+++ b/drivers/staging/rtl8723au/include/osdep_service.h
@@ -149,70 +149,6 @@ extern unsigned char MCS_rate_1R23A[16];
149void _rtw_init_queue23a(struct rtw_queue *pqueue); 149void _rtw_init_queue23a(struct rtw_queue *pqueue);
150u32 _rtw_queue_empty23a(struct rtw_queue *pqueue); 150u32 _rtw_queue_empty23a(struct rtw_queue *pqueue);
151 151
152u32 rtw_get_current_time(void);
153u32 rtw_systime_to_ms23a(u32 systime);
154u32 rtw_ms_to_systime23a(u32 ms);
155s32 rtw_get_passing_time_ms23a(u32 start);
156s32 rtw_get_time_interval_ms23a(u32 start, u32 end);
157
158#define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r))
159#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2)
160
161static inline u32 _RND4(u32 sz)
162{
163
164 u32 val;
165
166 val = ((sz >> 2) + ((sz & 3) ? 1: 0)) << 2;
167
168 return val;
169
170}
171
172static inline u32 _RND8(u32 sz)
173{
174
175 u32 val;
176
177 val = ((sz >> 3) + ((sz & 7) ? 1: 0)) << 3;
178
179 return val;
180
181}
182
183static inline u32 _RND128(u32 sz)
184{
185
186 u32 val;
187
188 val = ((sz >> 7) + ((sz & 127) ? 1: 0)) << 7;
189
190 return val;
191
192}
193
194static inline u32 _RND256(u32 sz)
195{
196
197 u32 val;
198
199 val = ((sz >> 8) + ((sz & 255) ? 1: 0)) << 8;
200
201 return val;
202
203}
204
205static inline u32 _RND512(u32 sz)
206{
207
208 u32 val;
209
210 val = ((sz >> 9) + ((sz & 511) ? 1: 0)) << 9;
211
212 return val;
213
214}
215
216static inline u32 bitshift(u32 bitmask) 152static inline u32 bitshift(u32 bitmask)
217{ 153{
218 u32 i; 154 u32 i;
@@ -223,20 +159,11 @@ static inline u32 bitshift(u32 bitmask)
223 return i; 159 return i;
224} 160}
225 161
226#define STRUCT_PACKED __attribute__ ((packed))
227
228/* limitation of path length */
229#define PATH_LENGTH_MAX PATH_MAX
230
231void rtw_suspend_lock_init(void); 162void rtw_suspend_lock_init(void);
232void rtw_suspend_lock_uninit(void); 163void rtw_suspend_lock_uninit(void);
233void rtw_lock_suspend(void); 164void rtw_lock_suspend(void);
234void rtw_unlock_suspend(void); 165void rtw_unlock_suspend(void);
235 166
236/* File operation APIs, just for linux now */
237int rtw_is_file_readable(char *path);
238int rtw_retrive_from_file(char *path, u8* buf, u32 sz);
239int rtw_store_to_file(char *path, u8* buf, u32 sz);
240 167
241#define NDEV_FMT "%s" 168#define NDEV_FMT "%s"
242#define NDEV_ARG(ndev) ndev->name 169#define NDEV_ARG(ndev) ndev->name
@@ -255,69 +182,9 @@ u64 rtw_division6423a(u64 x, u64 y);
255 182
256/* Macros for handling unaligned memory accesses */ 183/* Macros for handling unaligned memory accesses */
257 184
258#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1]))
259#define RTW_PUT_BE16(a, val) \
260 do { \
261 (a)[0] = ((u16) (val)) >> 8; \
262 (a)[1] = ((u16) (val)) & 0xff; \
263 } while (0)
264
265#define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0]))
266#define RTW_PUT_LE16(a, val) \
267 do { \
268 (a)[1] = ((u16) (val)) >> 8; \
269 (a)[0] = ((u16) (val)) & 0xff; \
270 } while (0)
271
272#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ 185#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
273 ((u32) (a)[2])) 186 ((u32) (a)[2]))
274#define RTW_PUT_BE24(a, val) \
275 do { \
276 (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \
277 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
278 (a)[2] = (u8) (((u32) (val)) & 0xff); \
279 } while (0)
280
281#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \
282 (((u32) (a)[2]) << 8) | ((u32) (a)[3]))
283#define RTW_PUT_BE32(a, val) \
284 do { \
285 (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \
286 (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \
287 (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \
288 (a)[3] = (u8) (((u32) (val)) & 0xff); \
289 } while (0)
290
291#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \
292 (((u32) (a)[1]) << 8) | ((u32) (a)[0]))
293#define RTW_PUT_LE32(a, val) \
294 do { \
295 (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \
296 (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \
297 (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \
298 (a)[0] = (u8) (((u32) (val)) & 0xff); \
299 } while (0)
300
301#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \
302 (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \
303 (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \
304 (((u64) (a)[6]) << 8) | ((u64) (a)[7]))
305#define RTW_PUT_BE64(a, val) \
306 do { \
307 (a)[0] = (u8) (((u64) (val)) >> 56); \
308 (a)[1] = (u8) (((u64) (val)) >> 48); \
309 (a)[2] = (u8) (((u64) (val)) >> 40); \
310 (a)[3] = (u8) (((u64) (val)) >> 32); \
311 (a)[4] = (u8) (((u64) (val)) >> 24); \
312 (a)[5] = (u8) (((u64) (val)) >> 16); \
313 (a)[6] = (u8) (((u64) (val)) >> 8); \
314 (a)[7] = (u8) (((u64) (val)) & 0xff); \
315 } while (0)
316 187
317#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \
318 (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \
319 (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \
320 (((u64) (a)[1]) << 8) | ((u64) (a)[0]))
321 188
322struct rtw_cbuf { 189struct rtw_cbuf {
323 u32 write; 190 u32 write;
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h
index 5777eda01403..6d1edc6ef84d 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h
@@ -1074,7 +1074,7 @@ struct packet_irp_acl_data {
1074struct packet_irp_hcievent_data { 1074struct packet_irp_hcievent_data {
1075 u8 EventCode; 1075 u8 EventCode;
1076 u8 Length; 1076 u8 Length;
1077 u8 Data[5]; 1077 u8 Data[20];
1078}; 1078};
1079 1079
1080struct common_triple { 1080struct common_triple {
@@ -1332,7 +1332,7 @@ struct bt_coexist_8723a {
1332 u8 c2hBtInfoOriginal; 1332 u8 c2hBtInfoOriginal;
1333 u8 prec2hBtInfo; /* for 1Ant */ 1333 u8 prec2hBtInfo; /* for 1Ant */
1334 u8 bC2hBtInquiryPage; 1334 u8 bC2hBtInquiryPage;
1335 u64 btInqPageStartTime; /* for 2Ant */ 1335 unsigned long btInqPageStartTime; /* for 2Ant */
1336 u8 c2hBtProfile; /* for 1Ant */ 1336 u8 c2hBtProfile; /* for 1Ant */
1337 u8 btRetryCnt; 1337 u8 btRetryCnt;
1338 u8 btInfoExt; 1338 u8 btInfoExt;
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_pg.h b/drivers/staging/rtl8723au/include/rtl8723a_pg.h
index 12f7a1326b4c..5c2ec448e568 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_pg.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_pg.h
@@ -15,9 +15,7 @@
15#ifndef __RTL8723A_PG_H__ 15#ifndef __RTL8723A_PG_H__
16#define __RTL8723A_PG_H__ 16#define __RTL8723A_PG_H__
17 17
18/* */
19/* EEPROM/Efuse PG Offset for 8723E/8723U/8723S */ 18/* EEPROM/Efuse PG Offset for 8723E/8723U/8723S */
20/* */
21#define EEPROM_CCK_TX_PWR_INX_8723A 0x10 19#define EEPROM_CCK_TX_PWR_INX_8723A 0x10
22#define EEPROM_HT40_1S_TX_PWR_INX_8723A 0x16 20#define EEPROM_HT40_1S_TX_PWR_INX_8723A 0x16
23#define EEPROM_HT20_TX_PWR_INX_DIFF_8723A 0x1C 21#define EEPROM_HT20_TX_PWR_INX_DIFF_8723A 0x1C
@@ -53,31 +51,24 @@
53/* RTL8723AS */ 51/* RTL8723AS */
54#define EEPROM_MAC_ADDR_8723AS 0xAA 52#define EEPROM_MAC_ADDR_8723AS 0xAA
55 53
56/* */
57/* EEPROM/Efuse Value Type */ 54/* EEPROM/Efuse Value Type */
58/* */
59#define EETYPE_TX_PWR 0x0 55#define EETYPE_TX_PWR 0x0
60 56
61/* */
62/* EEPROM/Efuse Default Value */ 57/* EEPROM/Efuse Default Value */
63/* */
64#define EEPROM_Default_CrystalCap_8723A 0x20 58#define EEPROM_Default_CrystalCap_8723A 0x20
65 59
66 60
67/* */
68/* EEPROM/EFUSE data structure definition. */ 61/* EEPROM/EFUSE data structure definition. */
69/* */
70#define MAX_RF_PATH_NUM 2
71#define MAX_CHNL_GROUP 3+9 62#define MAX_CHNL_GROUP 3+9
72 63
73struct txpowerinfo { 64struct txpowerinfo {
74 u8 CCKIndex[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 65 u8 CCKIndex[RF_PATH_MAX][MAX_CHNL_GROUP];
75 u8 HT40_1SIndex[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 66 u8 HT40_1SIndex[RF_PATH_MAX][MAX_CHNL_GROUP];
76 u8 HT40_2SIndexDiff[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 67 u8 HT40_2SIndexDiff[RF_PATH_MAX][MAX_CHNL_GROUP];
77 u8 HT20IndexDiff[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 68 u8 HT20IndexDiff[RF_PATH_MAX][MAX_CHNL_GROUP];
78 u8 OFDMIndexDiff[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 69 u8 OFDMIndexDiff[RF_PATH_MAX][MAX_CHNL_GROUP];
79 u8 HT40MaxOffset[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 70 u8 HT40MaxOffset[RF_PATH_MAX][MAX_CHNL_GROUP];
80 u8 HT20MaxOffset[MAX_RF_PATH_NUM][MAX_CHNL_GROUP]; 71 u8 HT20MaxOffset[RF_PATH_MAX][MAX_CHNL_GROUP];
81 u8 TSSI_A[3]; 72 u8 TSSI_A[3];
82 u8 TSSI_B[3]; 73 u8 TSSI_B[3];
83 u8 TSSI_A_5G[3]; /* 5GL/5GM/5GH */ 74 u8 TSSI_A_5G[3]; /* 5GL/5GM/5GH */
diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h
index adbea44d601f..31f96f39b498 100644
--- a/drivers/staging/rtl8723au/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723au/include/rtw_mlme.h
@@ -379,6 +379,28 @@ struct mlme_priv {
379 379
380 u8 *wps_probe_req_ie; 380 u8 *wps_probe_req_ie;
381 u32 wps_probe_req_ie_len; 381 u32 wps_probe_req_ie_len;
382 u8 *assoc_req;
383 u32 assoc_req_len;
384 u32 assoc_rsp_len;
385 u8 *assoc_rsp;
386 u32 wps_assoc_resp_ie_len;
387 u8 *wps_assoc_resp_ie;
388 u8 *wps_probe_resp_ie;
389 u32 wps_probe_resp_ie_len;
390 u8 *wps_beacon_ie;
391 u32 wps_beacon_ie_len;
392 u32 p2p_go_probe_resp_ie_len; /* for GO */
393 u32 p2p_assoc_req_ie_len;
394 u8 *p2p_beacon_ie;
395 u8 *p2p_probe_req_ie;
396 u8 *p2p_probe_resp_ie;
397 u8 *p2p_go_probe_resp_ie; /* for GO */
398 u8 *p2p_assoc_req_ie;
399 u32 p2p_beacon_ie_len;
400 u32 p2p_probe_req_ie_len;
401 u32 p2p_probe_resp_ie_len;
402 u8 *wfd_assoc_req_ie;
403 u32 wfd_assoc_req_ie_len;
382 404
383#ifdef CONFIG_8723AU_AP_MODE 405#ifdef CONFIG_8723AU_AP_MODE
384 /* Number of associated Non-ERP stations (i.e., stations using 802.11b 406 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
@@ -407,50 +429,20 @@ struct mlme_priv {
407 429
408 u16 ht_op_mode; 430 u16 ht_op_mode;
409 431
410 u8 *assoc_req;
411 u32 assoc_req_len;
412 u8 *assoc_rsp;
413 u32 assoc_rsp_len;
414
415 u8 *wps_beacon_ie;
416 /* u8 *wps_probe_req_ie; */
417 u8 *wps_probe_resp_ie;
418 u8 *wps_assoc_resp_ie;
419
420 u32 wps_beacon_ie_len;
421 /* u32 wps_probe_req_ie_len; */
422 u32 wps_probe_resp_ie_len;
423 u32 wps_assoc_resp_ie_len;
424
425 u8 *p2p_beacon_ie;
426 u8 *p2p_probe_req_ie;
427 u8 *p2p_probe_resp_ie;
428 u8 *p2p_go_probe_resp_ie; /* for GO */
429 u8 *p2p_assoc_req_ie;
430
431 u32 p2p_beacon_ie_len;
432 u32 p2p_probe_req_ie_len;
433 u32 p2p_probe_resp_ie_len;
434 u32 p2p_go_probe_resp_ie_len; /* for GO */
435 u32 p2p_assoc_req_ie_len;
436 spinlock_t bcn_update_lock; 432 spinlock_t bcn_update_lock;
437 u8 update_bcn; 433 u8 update_bcn;
438 434
439#endif /* ifdef CONFIG_8723AU_AP_MODE */ 435#endif /* ifdef CONFIG_8723AU_AP_MODE */
440 436
441#if defined(CONFIG_8723AU_P2P)
442 u8 *wfd_beacon_ie; 437 u8 *wfd_beacon_ie;
443 u8 *wfd_probe_req_ie; 438 u8 *wfd_probe_req_ie;
444 u8 *wfd_probe_resp_ie; 439 u8 *wfd_probe_resp_ie;
445 u8 *wfd_go_probe_resp_ie; /* for GO */ 440 u8 *wfd_go_probe_resp_ie; /* for GO */
446 u8 *wfd_assoc_req_ie;
447 441
448 u32 wfd_beacon_ie_len; 442 u32 wfd_beacon_ie_len;
449 u32 wfd_probe_req_ie_len; 443 u32 wfd_probe_req_ie_len;
450 u32 wfd_probe_resp_ie_len; 444 u32 wfd_probe_resp_ie_len;
451 u32 wfd_go_probe_resp_ie_len; /* for GO */ 445 u32 wfd_go_probe_resp_ie_len; /* for GO */
452 u32 wfd_assoc_req_ie_len;
453#endif
454}; 446};
455 447
456#ifdef CONFIG_8723AU_AP_MODE 448#ifdef CONFIG_8723AU_AP_MODE
diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
index d1c2d71295e5..0aaf0d5d8aea 100644
--- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
@@ -451,9 +451,7 @@ struct mlme_ext_priv {
451 451
452 u64 TSFValue; 452 u64 TSFValue;
453 453
454#ifdef CONFIG_8723AU_AP_MODE
455 unsigned char bstart_bss; 454 unsigned char bstart_bss;
456#endif
457 u8 update_channel_plan_by_ap_done; 455 u8 update_channel_plan_by_ap_done;
458 /* recv_decache check for Action_public frame */ 456 /* recv_decache check for Action_public frame */
459 u8 action_public_dialog_token; 457 u8 action_public_dialog_token;
diff --git a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
index b42e14198e8d..e0da87d4d3d6 100644
--- a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
+++ b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h
@@ -180,7 +180,7 @@ struct pwrctrl_priv {
180 u8 ips_mode; 180 u8 ips_mode;
181 u8 ips_mode_req; /* used to accept the mode setting request */ 181 u8 ips_mode_req; /* used to accept the mode setting request */
182 uint bips_processing; 182 uint bips_processing;
183 u32 ips_deny_time; /* will deny IPS when system time is smaller */ 183 unsigned long ips_deny_time; /* deny IPS when system time is smaller */
184 u8 ps_processing; /* used to mark whether in rtw_ps_processor23a */ 184 u8 ps_processing; /* used to mark whether in rtw_ps_processor23a */
185 185
186 u8 bLeisurePs; 186 u8 bLeisurePs;
diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h
index e2462e052e44..d1866a6e831f 100644
--- a/drivers/staging/rtl8723au/include/rtw_recv.h
+++ b/drivers/staging/rtl8723au/include/rtw_recv.h
@@ -17,6 +17,7 @@
17 17
18#include <osdep_service.h> 18#include <osdep_service.h>
19#include <drv_types.h> 19#include <drv_types.h>
20#include <Hal8723APhyCfg.h>
20 21
21#define NR_RECVFRAME 256 22#define NR_RECVFRAME 256
22 23
@@ -75,13 +76,11 @@ struct signal_stat {
75 u32 total_val; /* sum of valid elements */ 76 u32 total_val; /* sum of valid elements */
76}; 77};
77 78
78#define MAX_PATH_NUM_92CS 2
79
80struct phy_info { 79struct phy_info {
81 u8 RxPWDBAll; 80 u8 RxPWDBAll;
82 u8 SignalQuality; /* in 0-100 index. */ 81 u8 SignalQuality; /* in 0-100 index. */
83 u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ 82 u8 RxMIMOSignalQuality[RF_PATH_MAX]; /* EVM */
84 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* 0~100 */ 83 u8 RxMIMOSignalStrength[RF_PATH_MAX];/* 0~100 */
85 s8 RxPower; /* in dBm Translate from PWdB */ 84 s8 RxPower; /* in dBm Translate from PWdB */
86 /* Real power in dBm for this packet, no beautification and aggregation. 85 /* Real power in dBm for this packet, no beautification and aggregation.
87 * Keep this raw info to be used for the other procedures. 86 * Keep this raw info to be used for the other procedures.
@@ -89,8 +88,8 @@ struct phy_info {
89 s8 RecvSignalPower; 88 s8 RecvSignalPower;
90 u8 BTRxRSSIPercentage; 89 u8 BTRxRSSIPercentage;
91 u8 SignalStrength; /* in 0-100 index. */ 90 u8 SignalStrength; /* in 0-100 index. */
92 u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ 91 u8 RxPwr[RF_PATH_MAX];/* per-path's pwdb */
93 u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ 92 u8 RxSNR[RF_PATH_MAX];/* per-path's SNR */
94}; 93};
95 94
96 95
diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h
index 8af98ee77b07..ffbc9e3f2156 100644
--- a/drivers/staging/rtl8723au/include/sta_info.h
+++ b/drivers/staging/rtl8723au/include/sta_info.h
@@ -140,8 +140,6 @@ struct sta_info {
140 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */ 140 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
141 /* sta_info: (AP & STA) CAP/INFO */ 141 /* sta_info: (AP & STA) CAP/INFO */
142 142
143#ifdef CONFIG_8723AU_AP_MODE
144
145 struct list_head asoc_list; 143 struct list_head asoc_list;
146 struct list_head auth_list; 144 struct list_head auth_list;
147 145
@@ -183,11 +181,12 @@ struct sta_info {
183 u8 has_legacy_ac; 181 u8 has_legacy_ac;
184 unsigned int sleepq_ac_len; 182 unsigned int sleepq_ac_len;
185 183
186#ifdef CONFIG_8723AU_P2P
187 /* p2p priv data */ 184 /* p2p priv data */
188 u8 is_p2p_device; 185 u8 is_p2p_device;
189 u8 p2p_status_code; 186 u8 p2p_status_code;
190 187
188 u8 keep_alive_trycnt;
189
191 /* p2p client info */ 190 /* p2p client info */
192 u8 dev_addr[ETH_ALEN]; 191 u8 dev_addr[ETH_ALEN];
193 u8 dev_cap; 192 u8 dev_cap;
@@ -197,12 +196,6 @@ struct sta_info {
197 u8 secdev_types_list[32];/* 32/8 == 4; */ 196 u8 secdev_types_list[32];/* 32/8 == 4; */
198 u16 dev_name_len; 197 u16 dev_name_len;
199 u8 dev_name[32]; 198 u8 dev_name[32];
200#endif /* CONFIG_8723AU_P2P */
201
202 u8 keep_alive_trycnt;
203
204#endif /* CONFIG_8723AU_AP_MODE */
205
206 u8 *passoc_req; 199 u8 *passoc_req;
207 u32 assoc_req_len; 200 u32 assoc_req_len;
208 201
@@ -329,9 +322,6 @@ struct sta_priv {
329 struct rtw_queue wakeup_q; 322 struct rtw_queue wakeup_q;
330 323
331 struct rtw_adapter *padapter; 324 struct rtw_adapter *padapter;
332
333
334#ifdef CONFIG_8723AU_AP_MODE
335 struct list_head asoc_list; 325 struct list_head asoc_list;
336 struct list_head auth_list; 326 struct list_head auth_list;
337 spinlock_t asoc_list_lock; 327 spinlock_t asoc_list_lock;
@@ -357,7 +347,6 @@ struct sta_priv {
357 u16 max_num_sta; 347 u16 max_num_sta;
358 348
359 struct wlan_acl_pool acl_list; 349 struct wlan_acl_pool acl_list;
360#endif
361}; 350};
362 351
363static inline u32 wifi_mac_hash(u8 *mac) 352static inline u32 wifi_mac_hash(u8 *mac)
diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index 1c99616f51ac..50840b9a11fa 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -1495,9 +1495,11 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
1495 int ret = 0; 1495 int ret = 0;
1496 uint wps_ielen = 0; 1496 uint wps_ielen = 0;
1497 u8 *wps_ie; 1497 u8 *wps_ie;
1498#ifdef CONFIG_8723AU_P2P
1498 u32 p2p_ielen = 0; 1499 u32 p2p_ielen = 0;
1499 u8 *p2p_ie; 1500 u8 *p2p_ie;
1500 u32 wfd_ielen = 0; 1501 u32 wfd_ielen = 0;
1502#endif
1501 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1503 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1502 1504
1503#ifdef CONFIG_DEBUG_CFG80211 1505#ifdef CONFIG_DEBUG_CFG80211
@@ -1595,12 +1597,12 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
1595 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 1597 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1596 struct cfg80211_ssid ssid[RTW_SSID_SCAN_AMOUNT]; 1598 struct cfg80211_ssid ssid[RTW_SSID_SCAN_AMOUNT];
1597 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; 1599 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
1598#ifdef CONFIG_8723AU_P2P
1599 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
1600#endif /* CONFIG_8723AU_P2P */
1601 struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); 1600 struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev);
1602 struct cfg80211_ssid *ssids = request->ssids; 1601 struct cfg80211_ssid *ssids = request->ssids;
1602#ifdef CONFIG_8723AU_P2P
1603 struct wifidirect_info *pwdinfo = &padapter->wdinfo;
1603 int social_channel = 0; 1604 int social_channel = 0;
1605#endif /* CONFIG_8723AU_P2P */
1604 bool need_indicate_scan_done = false; 1606 bool need_indicate_scan_done = false;
1605 1607
1606#ifdef CONFIG_DEBUG_CFG80211 1608#ifdef CONFIG_DEBUG_CFG80211
@@ -1625,8 +1627,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy,
1625 goto check_need_indicate_scan_done; 1627 goto check_need_indicate_scan_done;
1626 } 1628 }
1627#ifdef CONFIG_8723AU_P2P 1629#ifdef CONFIG_8723AU_P2P
1628 if (ssids->ssid != NULL && 1630 if (!memcmp(ssids->ssid, "DIRECT-", 7) &&
1629 !memcmp(ssids->ssid, "DIRECT-", 7) &&
1630 rtw_get_p2p_ie23a((u8 *) request->ie, request->ie_len, NULL, NULL)) { 1631 rtw_get_p2p_ie23a((u8 *) request->ie, request->ie_len, NULL, NULL)) {
1631 if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { 1632 if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) {
1632 rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE); 1633 rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE);
@@ -2738,7 +2739,9 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
2738 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 2739 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
2739 u32 len = skb->len; 2740 u32 len = skb->len;
2740 u8 category, action; 2741 u8 category, action;
2742#ifdef CONFIG_8723AU_P2P
2741 int type = -1; 2743 int type = -1;
2744#endif
2742 2745
2743 if (rtw_action_frame_parse23a(skb->data, len, &category, 2746 if (rtw_action_frame_parse23a(skb->data, len, &category,
2744 &action) == false) { 2747 &action) == false) {
@@ -2760,7 +2763,9 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
2760 else 2763 else
2761 DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, 2764 DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category,
2762 action); 2765 action);
2766#ifdef CONFIG_8723AU_P2P
2763dump: 2767dump:
2768#endif
2764 /* starting alloc mgmt frame to dump it */ 2769 /* starting alloc mgmt frame to dump it */
2765 pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); 2770 pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
2766 if (pmgntframe == NULL) 2771 if (pmgntframe == NULL)
@@ -2971,8 +2976,10 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head,
2971 int ret = 0; 2976 int ret = 0;
2972 u8 *pbuf = NULL; 2977 u8 *pbuf = NULL;
2973 uint len, wps_ielen = 0; 2978 uint len, wps_ielen = 0;
2979#ifdef CONFIG_8723AU_P2P
2974 uint p2p_ielen = 0; 2980 uint p2p_ielen = 0;
2975 u8 got_p2p_ie = false; 2981 u8 got_p2p_ie = false;
2982#endif
2976 struct mlme_priv *pmlmepriv = &adapter->mlmepriv; 2983 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
2977 /* struct sta_priv *pstapriv = &padapter->stapriv; */ 2984 /* struct sta_priv *pstapriv = &padapter->stapriv; */
2978 2985
@@ -3245,7 +3252,9 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev,
3245void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, 3252void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame,
3246 uint frame_len) 3253 uint frame_len)
3247{ 3254{
3255#ifdef CONFIG_8723AU_P2P
3248 int type; 3256 int type;
3257#endif
3249 s32 freq; 3258 s32 freq;
3250 int channel; 3259 int channel;
3251 u8 category, action; 3260 u8 category, action;
@@ -3261,7 +3270,9 @@ void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame,
3261 rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); 3270 rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action);
3262 DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); 3271 DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action);
3263 3272
3273#ifdef CONFIG_8723AU_P2P
3264indicate: 3274indicate:
3275#endif
3265 if (channel <= RTW_CH_MAX_2G_CHANNEL) 3276 if (channel <= RTW_CH_MAX_2G_CHANNEL)
3266 freq = ieee80211_channel_to_frequency(channel, 3277 freq = ieee80211_channel_to_frequency(channel,
3267 IEEE80211_BAND_2GHZ); 3278 IEEE80211_BAND_2GHZ);
@@ -3276,7 +3287,9 @@ indicate:
3276void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, 3287void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter,
3277 u8 *pmgmt_frame, uint frame_len) 3288 u8 *pmgmt_frame, uint frame_len)
3278{ 3289{
3290#ifdef CONFIG_8723AU_P2P
3279 int type; 3291 int type;
3292#endif
3280 s32 freq; 3293 s32 freq;
3281 int channel; 3294 int channel;
3282 u8 category, action; 3295 u8 category, action;
@@ -3298,7 +3311,9 @@ void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter,
3298 rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); 3311 rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action);
3299 DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); 3312 DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action);
3300 3313
3314#ifdef CONFIG_8723AU_P2P
3301indicate: 3315indicate:
3316#endif
3302 if (channel <= RTW_CH_MAX_2G_CHANNEL) 3317 if (channel <= RTW_CH_MAX_2G_CHANNEL)
3303 freq = ieee80211_channel_to_frequency(channel, 3318 freq = ieee80211_channel_to_frequency(channel,
3304 IEEE80211_BAND_2GHZ); 3319 IEEE80211_BAND_2GHZ);
@@ -3485,7 +3500,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter,
3485 p2p_ie[p2pielen++] = P2P_ATTR_CAPABILITY; 3500 p2p_ie[p2pielen++] = P2P_ATTR_CAPABILITY;
3486 3501
3487 /* Length: */ 3502 /* Length: */
3488 RTW_PUT_LE16(p2p_ie + p2pielen, 0x0002); 3503 put_unaligned_le16(0x0002, p2p_ie + p2pielen);
3489 p2pielen += 2; 3504 p2pielen += 2;
3490 3505
3491 /* Value: */ 3506 /* Value: */
@@ -3499,7 +3514,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter,
3499 p2p_ie[p2pielen++] = P2P_ATTR_DEVICE_INFO; 3514 p2p_ie[p2pielen++] = P2P_ATTR_DEVICE_INFO;
3500 3515
3501 /* Length: */ 3516 /* Length: */
3502 RTW_PUT_LE16(p2p_ie + p2pielen, devinfo_contentlen); 3517 put_unaligned_le16(devinfo_contentlen, p2p_ie + p2pielen);
3503 p2pielen += 2; 3518 p2pielen += 2;
3504 3519
3505 /* Value: */ 3520 /* Value: */
@@ -3580,7 +3595,9 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy,
3580 3595
3581 del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); 3596 del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
3582 3597
3598#ifdef CONFIG_8723AU_P2P
3583 p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); 3599 p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK);
3600#endif
3584 } 3601 }
3585 3602
3586 pcfg80211_wdinfo->is_ro_ch = true; 3603 pcfg80211_wdinfo->is_ro_ch = true;
@@ -3663,7 +3680,9 @@ static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy,
3663 if (pcfg80211_wdinfo->is_ro_ch == true) { 3680 if (pcfg80211_wdinfo->is_ro_ch == true) {
3664 DBG_8723A("%s, cancel ro ch timer\n", __func__); 3681 DBG_8723A("%s, cancel ro ch timer\n", __func__);
3665 del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); 3682 del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
3683#ifdef CONFIG_8723AU_P2P
3666 p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); 3684 p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK);
3685#endif
3667 } 3686 }
3668 3687
3669 rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); 3688 rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo));
@@ -3834,7 +3853,9 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
3834 DBG_8723A("RTW_Tx:category(%u), action(%u)\n", 3853 DBG_8723A("RTW_Tx:category(%u), action(%u)\n",
3835 category, action); 3854 category, action);
3836 3855
3856#ifdef CONFIG_8723AU_P2P
3837dump: 3857dump:
3858#endif
3838 do { 3859 do {
3839 dump_cnt++; 3860 dump_cnt++;
3840 tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len); 3861 tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len);
@@ -3890,10 +3911,14 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
3890 int ret = 0; 3911 int ret = 0;
3891 uint wps_ielen = 0; 3912 uint wps_ielen = 0;
3892 u8 *wps_ie; 3913 u8 *wps_ie;
3914#ifdef CONFIG_8723AU_P2P
3893 u32 p2p_ielen = 0; 3915 u32 p2p_ielen = 0;
3894 u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 };
3895 u8 *p2p_ie;
3896 u32 wfd_ielen = 0; 3916 u32 wfd_ielen = 0;
3917 u8 *p2p_ie;
3918#endif
3919#ifdef CONFIG_8723AU_AP_MODE
3920 u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 };
3921#endif
3897 struct rtw_adapter *padapter = netdev_priv(ndev); 3922 struct rtw_adapter *padapter = netdev_priv(ndev);
3898 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 3923 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
3899 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; 3924 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
@@ -3923,8 +3948,10 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
3923 memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen); 3948 memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen);
3924 pmlmepriv->wps_beacon_ie_len = wps_ielen; 3949 pmlmepriv->wps_beacon_ie_len = wps_ielen;
3925 3950
3951#ifdef CONFIG_8723AU_AP_MODE
3926 update_beacon23a(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, 3952 update_beacon23a(padapter, _VENDOR_SPECIFIC_IE_, wps_oui,
3927 true); 3953 true);
3954#endif
3928 } 3955 }
3929#ifdef CONFIG_8723AU_P2P 3956#ifdef CONFIG_8723AU_P2P
3930 p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); 3957 p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen);
@@ -3992,12 +4019,14 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net,
3992{ 4019{
3993 struct rtw_adapter *padapter = netdev_priv(net); 4020 struct rtw_adapter *padapter = netdev_priv(net);
3994 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 4021 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
3995 int ret = 0; 4022#ifdef CONFIG_8723AU_P2P
3996 uint wps_ielen = 0;
3997 u8 *wps_ie;
3998 u32 p2p_ielen = 0; 4023 u32 p2p_ielen = 0;
3999 u8 *p2p_ie; 4024 u8 *p2p_ie;
4000 u32 wfd_ielen = 0; 4025 u32 wfd_ielen = 0;
4026#endif
4027 int ret = 0;
4028 uint wps_ielen = 0;
4029 u8 *wps_ie;
4001 4030
4002 if (len > 0) { 4031 if (len > 0) {
4003 wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); 4032 wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen);
@@ -4176,7 +4205,9 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len,
4176{ 4205{
4177 int ret = 0; 4206 int ret = 0;
4178 uint wps_ielen = 0; 4207 uint wps_ielen = 0;
4208#ifdef CONFIG_8723AU_P2P
4179 u32 p2p_ielen = 0; 4209 u32 p2p_ielen = 0;
4210#endif
4180 4211
4181#ifdef CONFIG_DEBUG_CFG80211 4212#ifdef CONFIG_DEBUG_CFG80211
4182 DBG_8723A("%s, ielen =%d\n", __func__, len); 4213 DBG_8723A("%s, ielen =%d\n", __func__, len);
diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c
index aeb48db0ee8c..97fc27dce19c 100644
--- a/drivers/staging/rtl8723au/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c
@@ -71,260 +71,6 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue)
71 return false; 71 return false;
72} 72}
73 73
74u32 rtw_get_current_time(void)
75{
76 return jiffies;
77}
78
79inline u32 rtw_systime_to_ms23a(u32 systime)
80{
81 return systime * 1000 / HZ;
82}
83
84inline u32 rtw_ms_to_systime23a(u32 ms)
85{
86 return ms * HZ / 1000;
87}
88
89/* the input parameter start use the same unit as returned
90 * by rtw_get_current_time
91 */
92inline s32 rtw_get_passing_time_ms23a(u32 start)
93{
94 return rtw_systime_to_ms23a(jiffies-start);
95}
96
97inline s32 rtw_get_time_interval_ms23a(u32 start, u32 end)
98{
99 return rtw_systime_to_ms23a(end-start);
100}
101
102#define RTW_SUSPEND_LOCK_NAME "rtw_wifi"
103
104inline void rtw_suspend_lock_init(void)
105{
106}
107
108inline void rtw_suspend_lock_uninit(void)
109{
110}
111
112inline void rtw_lock_suspend(void)
113{
114}
115
116inline void rtw_unlock_suspend(void)
117{
118}
119
120/* Open a file with the specific @param path, @param flag, @param mode
121 * @param fpp the pointer of struct file pointer to get struct
122 * file pointer while file opening is success
123 * @param path the path of the file to open
124 * @param flag file operation flags, please refer to linux document
125 * @param mode please refer to linux document
126 * @return Linux specific error code
127 */
128static int openFile(struct file **fpp, char *path, int flag, int mode)
129{
130 struct file *fp;
131
132 fp = filp_open(path, flag, mode);
133 if (IS_ERR(fp)) {
134 *fpp = NULL;
135 return PTR_ERR(fp);
136 } else {
137 *fpp = fp;
138 return 0;
139 }
140}
141
142/* Close the file with the specific @param fp
143 * @param fp the pointer of struct file to close
144 * @return always 0
145 */
146static int closeFile(struct file *fp)
147{
148 filp_close(fp, NULL);
149 return 0;
150}
151
152static int readFile(struct file *fp, char *buf, int len)
153{
154 int rlen = 0, sum = 0;
155
156 if (!fp->f_op || !fp->f_op->read)
157 return -EPERM;
158
159 while (sum < len) {
160 rlen = fp->f_op->read(fp, buf+sum, len-sum, &fp->f_pos);
161 if (rlen > 0)
162 sum += rlen;
163 else if (0 != rlen)
164 return rlen;
165 else
166 break;
167 }
168 return sum;
169}
170
171static int writeFile(struct file *fp, char *buf, int len)
172{
173 int wlen = 0, sum = 0;
174
175 if (!fp->f_op || !fp->f_op->write)
176 return -EPERM;
177
178 while (sum < len) {
179 wlen = fp->f_op->write(fp, buf+sum, len-sum, &fp->f_pos);
180 if (wlen > 0)
181 sum += wlen;
182 else if (0 != wlen)
183 return wlen;
184 else
185 break;
186 }
187 return sum;
188}
189
190/* Test if the specifi @param path is a file and readable
191 * @param path the path of the file to test
192 * @return Linux specific error code
193 */
194static int isFileReadable(char *path)
195{
196 struct file *fp;
197 int ret = 0;
198 mm_segment_t oldfs;
199 char buf;
200
201 fp = filp_open(path, O_RDONLY, 0);
202 if (IS_ERR(fp)) {
203 ret = PTR_ERR(fp);
204 } else {
205 oldfs = get_fs();
206 set_fs(get_ds());
207
208 if (1 != readFile(fp, &buf, 1))
209 ret = PTR_ERR(fp);
210
211 set_fs(oldfs);
212 filp_close(fp, NULL);
213 }
214 return ret;
215}
216
217/* Open the file with @param path and retrive the file content into
218 * memory starting from @param buf for @param sz at most
219 * @param path the path of the file to open and read
220 * @param buf the starting address of the buffer to store file content
221 * @param sz how many bytes to read at most
222 * @return the byte we've read, or Linux specific error code
223 */
224static int retriveFromFile(char *path, u8 *buf, u32 sz)
225{
226 int ret = -1;
227 mm_segment_t oldfs;
228 struct file *fp;
229
230 if (path && buf) {
231 ret = openFile(&fp, path, O_RDONLY, 0);
232 if (!ret) {
233 DBG_8723A("%s openFile path:%s fp =%p\n",
234 __func__, path, fp);
235
236 oldfs = get_fs(); set_fs(get_ds());
237 ret = readFile(fp, buf, sz);
238 set_fs(oldfs);
239 closeFile(fp);
240
241 DBG_8723A("%s readFile, ret:%d\n", __func__, ret);
242 } else {
243 DBG_8723A("%s openFile path:%s Fail, ret:%d\n",
244 __func__, path, ret);
245 }
246 } else {
247 DBG_8723A("%s NULL pointer\n", __func__);
248 ret = -EINVAL;
249 }
250 return ret;
251}
252
253/* Open the file with @param path and wirte @param sz byte of data starting
254 * from @param buf into the file
255 * @param path the path of the file to open and write
256 * @param buf the starting address of the data to write into file
257 * @param sz how many bytes to write at most
258 * @return the byte we've written, or Linux specific error code
259 */
260static int storeToFile(char *path, u8 *buf, u32 sz)
261{
262 struct file *fp;
263 int ret = 0;
264 mm_segment_t oldfs;
265
266 if (path && buf) {
267 ret = openFile(&fp, path, O_CREAT|O_WRONLY, 0666);
268 if (!ret) {
269 DBG_8723A("%s openFile path:%s fp =%p\n", __func__,
270 path, fp);
271
272 oldfs = get_fs(); set_fs(get_ds());
273 ret = writeFile(fp, buf, sz);
274 set_fs(oldfs);
275 closeFile(fp);
276
277 DBG_8723A("%s writeFile, ret:%d\n", __func__, ret);
278 } else {
279 DBG_8723A("%s openFile path:%s Fail, ret:%d\n",
280 __func__, path, ret);
281 }
282 } else {
283 DBG_8723A("%s NULL pointer\n", __func__);
284 ret = -EINVAL;
285 }
286 return ret;
287}
288
289/*
290* Test if the specifi @param path is a file and readable
291* @param path the path of the file to test
292* @return true or false
293*/
294int rtw_is_file_readable(char *path)
295{
296 if (isFileReadable(path) == 0)
297 return true;
298 else
299 return false;
300}
301
302/* Open the file with @param path and retrive the file content into memoryi
303 * starting from @param buf for @param sz at most
304 * @param path the path of the file to open and read
305 * @param buf the starting address of the buffer to store file content
306 * @param sz how many bytes to read at most
307 * @return the byte we've read
308 */
309int rtw_retrive_from_file(char *path, u8 *buf, u32 sz)
310{
311 int ret = retriveFromFile(path, buf, sz);
312 return ret >= 0 ? ret : 0;
313}
314
315/* Open the file with @param path and wirte @param sz byte of
316 * data starting from @param buf into the file
317 * @param path the path of the file to open and write
318 * @param buf the starting address of the data to write into file
319 * @param sz how many bytes to write at most
320 * @return the byte we've written
321 */
322int rtw_store_to_file(char *path, u8 *buf, u32 sz)
323{
324 int ret = storeToFile(path, buf, sz);
325 return ret >= 0 ? ret : 0;
326}
327
328u64 rtw_modular6423a(u64 x, u64 y) 74u64 rtw_modular6423a(u64 x, u64 y)
329{ 75{
330 return do_div(x, y); 76 return do_div(x, y);
diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c
index 040bf29b9d06..612806e0de2e 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c
@@ -664,8 +664,10 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
664 664
665 /* set mac addr */ 665 /* set mac addr */
666 rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr); 666 rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr);
667#ifdef CONFIG_8723AU_P2P
667 rtw_init_wifidirect_addrs23a(padapter, padapter->eeprompriv.mac_addr, 668 rtw_init_wifidirect_addrs23a(padapter, padapter->eeprompriv.mac_addr,
668 padapter->eeprompriv.mac_addr); 669 padapter->eeprompriv.mac_addr);
670#endif
669 671
670 DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n", 672 DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n",
671 padapter->bDriverStopped, padapter->bSurpriseRemoved, 673 padapter->bDriverStopped, padapter->bSurpriseRemoved,
@@ -811,12 +813,9 @@ static void rtw_disconnect(struct usb_interface *pusb_intf)
811 return; 813 return;
812} 814}
813 815
814extern int console_suspend_enabled;
815
816static int __init rtw_drv_entry(void) 816static int __init rtw_drv_entry(void)
817{ 817{
818 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n")); 818 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n"));
819 rtw_suspend_lock_init();
820 return usb_register(usb_drv); 819 return usb_register(usb_drv);
821} 820}
822 821
@@ -825,8 +824,6 @@ static void __exit rtw_drv_halt(void)
825 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); 824 RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n"));
826 DBG_8723A("+rtw_drv_halt\n"); 825 DBG_8723A("+rtw_drv_halt\n");
827 826
828 rtw_suspend_lock_uninit();
829
830 usb_deregister(usb_drv); 827 usb_deregister(usb_drv);
831 828
832 DBG_8723A("-rtw_drv_halt\n"); 829 DBG_8723A("-rtw_drv_halt\n");