staging: r8188eu: use round_up()
cover staging: r8188eu: use round_up()
This series converts the driver to use the in-kernel round_up() instead of custom _RND* implementations.
Tested on x86_64 with Inter-Tech DMG-02.
Michael Straube (5):
staging: r8188eu: use round_up() instead of RND4()
staging: r8188eu: use round_up() instead of _RND4()
staging: r8188eu: use round_up() instead of _RND8()
staging: r8188eu: use round_up() instead of _RND128()
staging: r8188eu: remove unused _RND* from osdep_service.h
drivers/staging/r8188eu/core/rtw_cmd.c | 2 +- drivers/staging/r8188eu/core/rtw_security.c | 6 +-- drivers/staging/r8188eu/core/rtw_xmit.c | 4 +- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 8 ++-- drivers/staging/r8188eu/hal/usb_ops_linux.c | 2 +- .../staging/r8188eu/include/osdep_service.h | 43 ------------------- 6 files changed, 11 insertions(+), 54 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/5 staging: r8188eu: use round_up() instead of RND4()
Use in-kernel round_up() instead of custom RND4().
--- drivers/staging/r8188eu/core/rtw_security.c | 6 +++--- drivers/staging/r8188eu/core/rtw_xmit.c | 4 ++-- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 1 - 4 files changed, 6 insertions(+), 7 deletions(-)
drivers/staging/r8188eu/core/rtw_security.c +3 -3
@@ -63,7 +63,7 @@ void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((size_t )(pframe)); + pframe = (u8 *)round_up ((size_t )pframe,4 ); } } }
@@ -504,7 +504,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((size_t )(pframe)); + pframe = (u8 *)round_up ((size_t )pframe,4 ); } } }else {
@@ -1133,7 +1133,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)aes_cipher (prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((size_t )(pframe)); + pframe = (u8 *)round_up ((size_t )pframe,4 ); } } }else {
drivers/staging/r8188eu/core/rtw_xmit.c +2 -2
@@ -642,7 +642,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_t )(payload)); + payload = (u8 *)round_up ((size_t )payload,4 ); payload = payload + pattrib->hdrlen + pattrib->iv_len;if ((curfragnum +1 ) == pattrib->nr_frags) {
@@ -987,7 +987,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct addr = (size_t )(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/r8188eu/hal/rtl8188eu_xmit.c +1 -1
@@ -347,7 +347,7 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) mem_addr += w_sz; - mem_addr = (u8 *)RND4 (((size_t )(mem_addr))); + mem_addr = (u8 *)round_up ((size_t )mem_addr,4 ); }rtw_free_xmitframe (pxmitpriv, pxmitframe);
drivers/staging/r8188eu/include/osdep_service.h +0 -1
@@ -95,7 +95,6 @@ static inline void flush_signals_thread(void) }#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.35.1
Re: [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4()
Quoted 1 line · Michael Straube
Use in-kernel
round_up()instead of customRND4().
[]
drivers/staging/r8188eu/core/rtw_security.c
Quoted 1 line
drivers/staging/r8188eu/core/rtw_security.c +0
-0
[]
drivers/staging/r8188eu/core/rtw_security.c void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) · line 66
Quoted 6 lines
drivers/staging/r8188eu/core/rtw_security.c +1
-1@@ -63,7 +63,7 @@ void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((size_t )(pframe)); + pframe = (u8 *)round_up ((size_t )pframe,4 );
Perhaps use PTR_ALIGN
pframe = PTR_ALIGN(pframe, 4);
etc...
Re: [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4()
Quoted 14 lines · Joe Perches
Quoted 1 line · Michael Straube
Use in-kernel
round_up()instead of customRND4().[]
drivers/staging/r8188eu/core/rtw_security.c
Quoted 1 line
drivers/staging/r8188eu/core/rtw_security.c +0
-0[]
drivers/staging/r8188eu/core/rtw_security.c void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) · line 66
Quoted 6 lines
drivers/staging/r8188eu/core/rtw_security.c +1
-1@@ -63,7 +63,7 @@ void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)arc4_crypt (ctx, payload + length, crc.f1,4 ); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4 ((size_t )(pframe)); + pframe = (u8 *)round_up ((size_t )pframe,4 );Perhaps use
PTR_ALIGN
Quoted 3 lines
pframe = PTR_ALIGN(pframe, 4);etc...
Sounds reasonable, I'll send v2 soon.
Thanks,
Michael
PATCH 2/5 staging: r8188eu: use round_up() instead of _RND4()
In reply to Michael StraubeUse in-kernel round_up() instead of custom _RND4().
--- drivers/staging/r8188eu/core/rtw_cmd.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-)
drivers/staging/r8188eu/core/rtw_cmd.c +1 -1
@@ -264,7 +264,7 @@ int rtw_cmd_thread(void *context) goto post_process; } - pcmd->cmdsz =_RND4 ((pcmd->cmdsz));/* _RND4 */ + pcmd->cmdsz =round_up (pcmd->cmdsz,4 );memcpy (pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
drivers/staging/r8188eu/include/osdep_service.h +0 -8
@@ -96,14 +96,6 @@ static inline void flush_signals_thread(void)#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) {u32 val;
Signature · 1 line
2.35.1
PATCH 3/5 staging: r8188eu: use round_up() instead of _RND8()
In reply to Michael StraubeUse in-kernel round_up() instead of custom _RND8().
--- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 6 +++--- drivers/staging/r8188eu/include/osdep_service.h | 8 -------- 2 files changed, 3 insertions(+), 11 deletions(-)
drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +3 -3
@@ -437,7 +437,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit pfirstframe = pxmitframe; len =xmitframe_need_length (pfirstframe) +TXDESC_SIZE + (pfirstframe->pkt_offset *PACKET_OFFSET_SZ ); pbuf_tail = len; - pbuf =_RND8 (pbuf_tail); + pbuf =round_up (pbuf_tail,8 );/* check pkt amount in one bulk */ desc_cnt =0 ;
@@ -488,7 +488,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit len =xmitframe_need_length (pxmitframe) +TXDESC_SIZE + (pxmitframe->pkt_offset *PACKET_OFFSET_SZ ); -if (_RND8 (pbuf + len) >MAX_XMITBUF_SZ ) { +if (round_up (pbuf + len,8 ) >MAX_XMITBUF_SZ ) { pxmitframe->agg_num =1 ; pxmitframe->pkt_offset =1 ;break ;
@@ -511,7 +511,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit/* handle pointer and stop condition */ pbuf_tail = pbuf + len; - pbuf =_RND8 (pbuf_tail); + pbuf =round_up (pbuf_tail,8 ); pfirstframe->agg_num++;if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num)
drivers/staging/r8188eu/include/osdep_service.h +0 -8
@@ -96,14 +96,6 @@ static inline void flush_signals_thread(void)#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; -} -static inline u32 _RND128 (u32 sz) {u32 val;
Signature · 1 line
2.35.1
PATCH 4/5 staging: r8188eu: use round_up() instead of _RND128()
In reply to Michael StraubeUse in-kernel round_up() instead of custom _RND128().
--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-)
drivers/staging/r8188eu/hal/usb_ops_linux.c +1 -1
@@ -287,7 +287,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb)recvframe_put (precvframe, skb_len); - pkt_offset = (u16 )_RND128 (pkt_offset); + pkt_offset = (u16 )round_up (pkt_offset,128 );if (pattrib->pkt_rpt_type ==NORMAL_RX ) {/* Normal rx packet */ if (pattrib->physt)
drivers/staging/r8188eu/include/osdep_service.h +0 -8
@@ -96,14 +96,6 @@ static inline void flush_signals_thread(void)#define _RND (sz, r) ((((sz)+((r)-1))/(r))*(r)) -static inline u32 _RND128 (u32 sz) -{ -u32 val; - - val = ((sz >>7 ) + ((sz &127 ) ?1 :0 )) <<7 ; -return val; -} -static inline u32 _RND256 (u32 sz) {u32 val;
Signature · 1 line
2.35.1
PATCH 5/5 staging: r8188eu: remove unused _RND* from osdep_service.h
In reply to Michael StraubeRemove the unused macro _RND() and the unused functions _RND256(), _RND512() from osdep_service.h.
--- .../staging/r8188eu/include/osdep_service.h | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/staging/r8188eu/include/osdep_service.h +0 -18
@@ -94,24 +94,6 @@ static inline void flush_signals_thread(void)flush_signals (current); } -#define _RND (sz, r) ((((sz)+((r)-1))/(r))*(r)) - -static inline u32 _RND256 (u32 sz) -{ -u32 val; - - val = ((sz >>8 ) + ((sz &255 ) ?1 :0 )) <<8 ; -return val; -} - -static inline u32 _RND512 (u32 sz) -{ -u32 val; - - val = ((sz >>9 ) + ((sz &511 ) ?1 :0 )) <<9 ; -return val; -} -struct rtw_netdev_priv_indicator {void *priv;u32 sizeof_priv;
Signature · 1 line
2.35.1