staging: rtl8723bs: replace RND4 with round_up()
PATCH 1/8 staging: rtl8723bs: replace RND4 with round_up()
Use round_up instead of define RND4.
--- drivers/staging/rtl8723bs/core/rtw_security.c | 6 +++--- drivers/staging/rtl8723bs/core/rtw_xmit.c | 4 ++-- drivers/staging/rtl8723bs/hal/sdio_ops.c | 6 +++--- drivers/staging/rtl8723bs/include/osdep_service.h | 1 - 4 files changed, 8 insertions(+), 9 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +3 -3
@@ -260,7 +260,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)arcfour_encrypt (&mycontext, payload+length, crc,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((SIZE_PTR )(pframe)); + pframe = (u8 *)round_up ((SIZE_PTR )(pframe),4 ); } }
@@ -716,7 +716,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)arcfour_encrypt (&mycontext, payload+length, crc,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((SIZE_PTR )(pframe)); + pframe = (u8 *)round_up ((SIZE_PTR )(pframe),4 ); } }
@@ -1523,7 +1523,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)aes_cipher (prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((SIZE_PTR )(pframe)); + pframe = (u8 *)round_up ((SIZE_PTR )(pframe),4 ); } }
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -2
@@ -865,7 +865,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr payload = pframe;for (curfragnum =0 ; curfragnum < pattrib->nr_frags; curfragnum++) { - payload = (u8 *)RND4 ((SIZE_PTR )(payload)); + payload = (u8 *)round_up ((SIZE_PTR )(payload),4 );RT_TRACE (_module_rtl871x_xmit_c_, _drv_err_, ("===curfragnum =%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n" , curfragnum, *payload, *(payload+1 ), *(payload+2 ), *(payload+3 ), *(payload+4 ), *(payload+5 ), *(payload+6 ), *(payload+7 )));
@@ -1209,7 +1209,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram addr = (SIZE_PTR )(pframe); - mem_start = (unsigned char *)RND4 (addr) + hw_hdr_offset; + mem_start = (unsigned char *)round_up (addr,4 ) + hw_hdr_offset;memcpy (mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); }
drivers/staging/rtl8723bs/hal/sdio_ops.c +3 -3
@@ -534,7 +534,7 @@ static s32 _sdio_local_read(if (!mac_pwr_ctrl_on)return _sd_cmd52_read (intfhdl, addr, cnt, buf); - n =RND4 (cnt); + n =round_up (cnt,4 ); tmpbuf =rtw_malloc (n);if (!tmpbuf)return -1 ;
@@ -575,7 +575,7 @@ s32 sdio_local_read( )return sd_cmd52_read (intfhdl, addr, cnt, buf); - n =RND4 (cnt); + n =round_up (cnt,4 ); tmpbuf =rtw_malloc (n);if (!tmpbuf)return -1 ;
@@ -859,7 +859,7 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)/* Patch for some SDIO Host 4 bytes issue */ /* ex. RK3188 */ - readsize =RND4 (size); + readsize =round_up (size,4 );/* 3 1. alloc recvbuf */ recv_priv = &adapter->recvpriv;
drivers/staging/rtl8723bs/include/osdep_service.h +0 -1
@@ -131,7 +131,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par }#define _RND (sz, r) ((((sz)+((r)-1))/(r))*(r)) -#define RND4 (x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2)static inline u32 _RND4 (u32 sz) {
Signature · 1 line
2.26.2
PATCH 2/8 staging: rtl8723bs: replace _RND4 with round_up()
Use round_up instead of inline _RND4.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- drivers/staging/rtl8723bs/include/osdep_service.h | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
@@ -469,7 +469,7 @@ int rtw_cmd_thread(void *context) pcmdpriv->cmd_issued_cnt++; - pcmd->cmdsz =_RND4 ((pcmd->cmdsz));/* _RND4 */ + pcmd->cmdsz =round_up ((pcmd->cmdsz),4 );memcpy (pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
drivers/staging/rtl8723bs/hal/sdio_ops.c +1 -1
@@ -474,7 +474,7 @@ static u32 sdio_write_port(return _FAIL; } - cnt =_RND4 (cnt); + cnt =round_up (cnt,4 );HalSdioGetCmdAddr8723BSdio (adapter, addr, cnt >>2 , &addr);if (cnt > psdio->block_transfer_len)
drivers/staging/rtl8723bs/include/osdep_service.h +0 -11
@@ -132,17 +132,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par#define _RND (sz, r) ((((sz)+((r)-1))/(r))*(r)) -static inline u32 _RND4 (u32 sz) -{ - -u32 val; - - val = ((sz >>2 ) + ((sz &3 ) ?1 :0 )) <<2 ; - -return val; - -} -static inline u32 _RND8 (u32 sz) {
Signature · 1 line
2.26.2
PATCH 7/8 staging: rtl8723bs: replace RTW_GET_BE16 with get_unaligned_be16
In reply to Ross SchmidtReplace RTW_GET_BE16 macro with get_unlaligned_be16.
--- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_recv.c | 3 ++- drivers/staging/rtl8723bs/include/osdep_service.h | 2 -- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 3 ++- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +2 -2
@@ -801,8 +801,8 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attwhile (attr_ptr - wps_ie < wps_ielen) {/* 4 = 2(Attribute ID) + 2(Length) */ -u16 attr_id =RTW_GET_BE16 (attr_ptr); -u16 attr_data_len =RTW_GET_BE16 (attr_ptr +2 ); +u16 attr_id =get_unaligned_be16 (attr_ptr); +u16 attr_data_len =get_unaligned_be16 (attr_ptr +2 );u16 attr_len = attr_data_len +4 ;/* DBG_871X("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */
drivers/staging/rtl8723bs/core/rtw_recv.c +2 -1
@@ -11,6 +11,7 @@#include <linux/jiffies.h> #include <rtw_recv.h> #include <net/cfg80211.h> +#include <asm/unaligned.h> static u8 SNAP_ETH_TYPE_IPX [2 ] = {0x81 ,0x37 };static u8 SNAP_ETH_TYPE_APPLETALK_AARP [2 ] = {0x80 ,0xf3 };
@@ -1906,7 +1907,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)while (a_len >ETH_HLEN ) {/* Offset 12 denote 2 mac address */ - nSubframe_Length =RTW_GET_BE16 (pdata +12 ); + nSubframe_Length =get_unaligned_be16 (pdata +12 );if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {DBG_871X ("nRemain_Length is %d and nSubframe_Length is : %d\n" , a_len, nSubframe_Length);
drivers/staging/rtl8723bs/include/osdep_service.h +0 -2
@@ -150,8 +150,6 @@ extern void rtw_free_netdev(struct net_device * netdev);/* Macros for handling unaligned memory accesses */ -#define RTW_GET_BE16 (a) ((u16) (((a)[0] << 8) | (a)[1])) -void rtw_buf_free (u8 **buf,u32 *buf_len);void rtw_buf_update (u8 **buf,u32 *buf_len,u8 *src,u32 src_len);
drivers/staging/rtl8723bs/os_dep/recv_linux.c +2 -1
@@ -10,6 +10,7 @@#include <rtw_debug.h> #include <linux/jiffies.h> #include <net/cfg80211.h> +#include <asm/unaligned.h> void rtw_os_free_recvframe (union recv_frame *precvframe) {
@@ -69,7 +70,7 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8skb_reserve (sub_skb,12 );skb_put_data (sub_skb, (pdata +ETH_HLEN ), nSubframe_Length); - eth_type =RTW_GET_BE16 (&sub_skb->data[6 ]); + eth_type =get_unaligned_be16 (&sub_skb->data[6 ]); if (sub_skb->len >= 8 && ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
Signature · 1 line
2.26.2
PATCH 6/8 staging: rtl8723bs: replace RTW_GET_LE16 with get_unaligned_le16
In reply to Ross SchmidtReplace RTW_GET_LE16 macro with get_unaligned_le16.
--- drivers/staging/rtl8723bs/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 7 ++++--- drivers/staging/rtl8723bs/include/osdep_service.h | 2 -- 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ap.c +3 -2
@@ -8,6 +8,7 @@#include <drv_types.h> #include <rtw_debug.h> +#include <asm/unaligned.h> extern unsigned char RTW_WPA_OUI [];extern unsigned char WMM_OUI [];
@@ -995,12 +996,12 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)/* beacon interval */ p =rtw_get_beacon_interval_from_ie (ie);/* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ /* pbss_network->Configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p); */ - pbss_network->Configuration.BeaconPeriod =RTW_GET_LE16 (p); + pbss_network->Configuration.BeaconPeriod =get_unaligned_le16 (p);/* capability */ /* cap = *(unsigned short *)rtw_get_capability_from_ie(ie); */ /* cap = le16_to_cpu(cap); */ - cap =RTW_GET_LE16 (ie); + cap =get_unaligned_le16 (ie);/* SSID */ p = rtw_get_ie(
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +2 -2
@@ -500,7 +500,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis/* pairwise_cipher */ if (left >=2 ) {/* count = le16_to_cpu(*(u16*)pos); */ - count =RTW_GET_LE16 (pos); + count =get_unaligned_le16 (pos); pos +=2 ; left -=2 ;
@@ -570,7 +570,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi/* pairwise_cipher */ if (left >=2 ) {/* count = le16_to_cpu(*(u16*)pos); */ - count =RTW_GET_LE16 (pos); + count =get_unaligned_le16 (pos); pos +=2 ; left -=2 ;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +4 -3
@@ -11,6 +11,7 @@#include <rtw_wifi_regd.h> #include <hal_btcoex.h> #include <linux/kernel.h> +#include <asm/unaligned.h> static struct mlme_handler mlme_sta_tbl[] = { {WIFI_ASSOCREQ ,"OnAssocReq" , &OnAssocReq},
@@ -1213,7 +1214,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto asoc_class2_error; } - capab_info =RTW_GET_LE16 (pframe +WLAN_HDR_A3_LEN ); + capab_info =get_unaligned_le16 (pframe +WLAN_HDR_A3_LEN );/* capab_info = le16_to_cpu(*(unsigned short *)(pframe + WLAN_HDR_A3_LEN)); */ left = pkt_len - (sizeof (struct ieee80211_hdr_3addr ) + ie_offset);
@@ -1959,7 +1960,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frabreak ;case RTW_WLAN_ACTION_ADDBA_RESP :/* ADDBA response */ - status =RTW_GET_LE16 (&frame_body[3 ]); + status =get_unaligned_le16 (&frame_body[3 ]); tid = ((frame_body[5 ] >>2 ) &0x7 );if (status ==0 ) {
@@ -1989,7 +1990,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra ~BIT ((frame_body[3 ] >>4 ) &0xf );/* reason_code = frame_body[4] | (frame_body[5] << 8); */ - reason_code =RTW_GET_LE16 (&frame_body[4 ]); + reason_code =get_unaligned_le16 (&frame_body[4 ]); }else if ((frame_body[3 ] &BIT (3 )) ==BIT (3 )) { tid = (frame_body[3 ] >>4 ) &0x0F ;
drivers/staging/rtl8723bs/include/osdep_service.h +0 -2
@@ -152,8 +152,6 @@ extern void rtw_free_netdev(struct net_device * netdev);#define RTW_GET_BE16 (a) ((u16) (((a)[0] << 8) | (a)[1])) -#define RTW_GET_LE16 (a) ((u16) (((a)[1] << 8) | (a)[0])) -void rtw_buf_free (u8 **buf,u32 *buf_len);void rtw_buf_update (u8 **buf,u32 *buf_len,u8 *src,u32 src_len);
Signature · 1 line
2.26.2
PATCH 8/8 staging: rtl8723bs: replace _cancel_timer with del_timer_sync
In reply to Ross SchmidtReplace _cancel_timer with API function del_timer_sync.
One instance of del_timer_sync is moved and an unnecessary pair of spin locks are removed.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 3 +-- drivers/staging/rtl8723bs/core/rtw_mlme.c | 16 ++-------------- drivers/staging/rtl8723bs/hal/sdio_ops.c | 3 +-- .../rtl8723bs/include/osdep_service_linux.h | 6 ------ 4 files changed, 4 insertions(+), 24 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -2
@@ -2034,7 +2034,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)void rtw_createbss_cmd_callback (struct adapter *padapter,struct cmd_obj *pcmd) { -u8 timer_cancelled;struct sta_info *psta =NULL ;struct wlan_network *pwlan =NULL ;struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -2049,7 +2048,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)_set_timer (&pmlmepriv->assoc_timer,1 ); } -_cancel_timer (&pmlmepriv->assoc_timer, &timer_cancelled); +del_timer_sync (&pmlmepriv->assoc_timer);spin_lock_bh (&pmlmepriv->lock);
drivers/staging/rtl8723bs/core/rtw_mlme.c +2 -14
@@ -814,7 +814,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf)void rtw_surveydone_event_callback (struct adapter *adapter,u8 *pbuf) { -u8 timer_cancelled = false;struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);spin_lock_bh (&pmlmepriv->lock);
@@ -827,22 +826,12 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf)RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n" ,get_fwstate (pmlmepriv)));if (check_fwstate (pmlmepriv, _FW_UNDER_SURVEY)) { -/* u8 timer_cancelled; */ - - timer_cancelled = true; -/* _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); */ - +del_timer_sync (&pmlmepriv->scan_to_timer);_clr_fwstate_ (pmlmepriv, _FW_UNDER_SURVEY); }else {RT_TRACE (_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n" ,get_fwstate (pmlmepriv))); } -spin_unlock_bh (&pmlmepriv->lock); - -if (timer_cancelled) -_cancel_timer (&pmlmepriv->scan_to_timer, &timer_cancelled); - -spin_lock_bh (&pmlmepriv->lock);rtw_set_signal_stat_timer (&adapter->recvpriv);
@@ -1298,7 +1287,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_netvoid rtw_joinbss_event_prehandle (struct adapter *adapter,u8 *pbuf) {static u8 retry; -u8 timer_cancelled;struct sta_info *ptarget_sta =NULL , *pcur_sta =NULL ;struct sta_priv *pstapriv = &adapter->stapriv;struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
@@ -1392,7 +1380,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) }/* s5. Cancel assoc_timer */ -_cancel_timer (&pmlmepriv->assoc_timer, &timer_cancelled); +del_timer_sync (&pmlmepriv->assoc_timer);RT_TRACE (_module_rtl871x_mlme_c_, _drv_info_, ("Cancel assoc_timer\n" ));
drivers/staging/rtl8723bs/hal/sdio_ops.c +1 -2
@@ -945,8 +945,7 @@ void sd_int_dpc(struct adapter *adapter)if (hal->sdio_hisr &SDIO_HISR_CPWM1 ) {struct reportpwrstate_parm report; -u8 bcancelled; -_cancel_timer (&(pwrctl->pwr_rpwm_timer), &bcancelled); +del_timer_sync (&(pwrctl->pwr_rpwm_timer)); report.state =SdioLocalCmd52Read1Byte (adapter,SDIO_REG_HCPWM1_8723B );
drivers/staging/rtl8723bs/include/osdep_service_linux.h +0 -6
@@ -83,12 +83,6 @@ static inline void _set_timer(_timer *ptimer, u32 delay_time)mod_timer (ptimer, (jiffies + (delay_time *HZ /1000 ))); } -static inline void _cancel_timer (_timer *ptimer,u8 *bcancelled) -{ -del_timer_sync (ptimer); - *bcancelled = true;/* true == 1; false == 0 */ -} -static inline void _init_workitem (_workitem *pwork,void *pfunc,void *cntx) {INIT_WORK (pwork, pfunc);
Signature · 1 line
2.26.2
PATCH 5/8 staging: rtl8723bs: replace RTW_GET_BE24 with get_unaligned_be24
In reply to Ross SchmidtReplace RTW_GET_BE24 macro with get_unaligned_be24.
--- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 3 ++- drivers/staging/rtl8723bs/include/osdep_service.h | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_ieee80211.c +2 -1
@@ -9,6 +9,7 @@#include <drv_types.h> #include <rtw_debug.h> #include <linux/of.h> +#include <asm/unaligned.h> u8 RTW_WPA_OUI_TYPE [] = {0x00 ,0x50 ,0xf2 ,1 };u16 RTW_WPA_VERSION =1 ;
@@ -874,7 +875,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen,return -1 ; } - oui =RTW_GET_BE24 (pos); + oui =get_unaligned_be24 (pos);switch (oui) {case OUI_MICROSOFT :/* Microsoft/Wi-Fi information elements are further typed and
drivers/staging/rtl8723bs/include/osdep_service.h +0 -3
@@ -154,9 +154,6 @@ extern void rtw_free_netdev(struct net_device * netdev);#define RTW_GET_LE16 (a) ((u16) (((a)[1] << 8) | (a)[0])) -#define RTW_GET_BE24 (a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ - ((u32) (a)[2])) -void rtw_buf_free (u8 **buf,u32 *buf_len);void rtw_buf_update (u8 **buf,u32 *buf_len,u8 *src,u32 src_len);
Signature · 1 line
2.26.2
PATCH 4/8 staging: rtl8723bs: remove unused macros
In reply to Ross SchmidtRemove several macros in osdep_service.h because they are not used.
--- .../staging/rtl8723bs/include/osdep_service.h | 57 ------------------- 1 file changed, 57 deletions(-)
drivers/staging/rtl8723bs/include/osdep_service.h +0 -57
@@ -151,68 +151,11 @@ extern void rtw_free_netdev(struct net_device * netdev);/* Macros for handling unaligned memory accesses */ #define RTW_GET_BE16 (a) ((u16) (((a)[0] << 8) | (a)[1])) -#define RTW_PUT_BE16 (a, val) \ - do { \ - (a)[0] = ((u16) (val)) >> 8; \ - (a)[1] = ((u16) (val)) & 0xff; \ - } while (0)#define RTW_GET_LE16 (a) ((u16) (((a)[1] << 8) | (a)[0])) -#define RTW_PUT_LE16 (a, val) \ - do { \ - (a)[1] = ((u16) (val)) >> 8; \ - (a)[0] = ((u16) (val)) & 0xff; \ - } while (0)#define RTW_GET_BE24 (a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ ((u32) (a)[2])) -#define RTW_PUT_BE24 (a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[2] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE32 (a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ - (((u32) (a)[2]) << 8) | ((u32) (a)[3])) -#define RTW_PUT_BE32 (a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[3] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE32 (a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ - (((u32) (a)[1]) << 8) | ((u32) (a)[0])) -#define RTW_PUT_LE32 (a, val) \ - do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE64 (a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ - (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ - (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ - (((u64) (a)[6]) << 8) | ((u64) (a)[7])) -#define RTW_PUT_BE64 (a, val) \ - do { \ - (a)[0] = (u8) (((u64) (val)) >> 56); \ - (a)[1] = (u8) (((u64) (val)) >> 48); \ - (a)[2] = (u8) (((u64) (val)) >> 40); \ - (a)[3] = (u8) (((u64) (val)) >> 32); \ - (a)[4] = (u8) (((u64) (val)) >> 24); \ - (a)[5] = (u8) (((u64) (val)) >> 16); \ - (a)[6] = (u8) (((u64) (val)) >> 8); \ - (a)[7] = (u8) (((u64) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE64 (a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ - (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ - (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ - (((u64) (a)[1]) << 8) | ((u64) (a)[0]))void rtw_buf_free (u8 **buf,u32 *buf_len);void rtw_buf_update (u8 **buf,u32 *buf_len,u8 *src,u32 src_len);
Signature · 1 line
2.26.2
PATCH 3/8 staging: rtl8723bs: replace _RND8 with round_up()
In reply to Ross SchmidtUse round_up instead of inline _RND8.
--- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 2 +- drivers/staging/rtl8723bs/include/osdep_service.h | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +1 -1
@@ -369,7 +369,7 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t) } } - pkt_offset =_RND8 (pkt_offset); + pkt_offset =round_up (pkt_offset,8 ); precvbuf->pdata += pkt_offset; ptr = precvbuf->pdata; precvframe =NULL ;
drivers/staging/rtl8723bs/include/osdep_service.h +0 -11
@@ -132,17 +132,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par#define _RND (sz, r) ((((sz)+((r)-1))/(r))*(r)) -static inline u32 _RND8 (u32 sz) -{ - -u32 val; - - val = ((sz >>3 ) + ((sz &7 ) ?1 :0 )) <<3 ; - -return val; - -} -#ifndef MAC_FMT #define MAC_FMT "%pM"#endif
Signature · 1 line
2.26.2
From: Ross Schmidt
Quoted 3 lines
Sent: 04 October 2020 02:18
Use
round_upinstead of define RND4.
RND4 was also particularly horrid!
...
drivers/staging/rtl8723bs/core/rtw_security.c void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) · line 263
Quoted 11 lines
drivers/staging/rtl8723bs/core/rtw_security.c +1
-1@@ -260,7 +260,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)arcfour_encrypt (&mycontext, payload+length, crc,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((SIZE_PTR )(pframe)); + pframe = (u8 *)round_up ((SIZE_PTR )(pframe),4 );
I also suspect this is equivalent to:
pframe == round_up(pxmitpriv->frag_len, 4);
Does make one wonder whether the skipped bytes need to be zeroed though.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)