* [PATCH 0/5] staging: r8188eu: use round_up()
@ 2022-04-06 6:18 Michael Straube
2022-04-06 6:18 ` [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4() Michael Straube
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
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(-)
--
2.35.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4()
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
@ 2022-04-06 6:18 ` Michael Straube
2022-04-06 9:54 ` Joe Perches
2022-04-06 6:18 ` [PATCH 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel round_up() instead of custom RND4().
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
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(-)
diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
index 2cdcdfd5ca5c..7462eaab8d2e 100644
--- a/drivers/staging/r8188eu/core/rtw_security.c
+++ b/drivers/staging/r8188eu/core/rtw_security.c
@@ -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 {
diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index aede8ef8b098..0f84d9ade0a3 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -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);
}
diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
index 55032d7ae7e3..87095eff107b 100644
--- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
+++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
@@ -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);
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index fca8f3d116c2..56e5cbfec1f1 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -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)
{
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] staging: r8188eu: use round_up() instead of _RND4()
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-06 6:18 ` [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4() Michael Straube
@ 2022-04-06 6:18 ` Michael Straube
2022-04-06 6:18 ` [PATCH 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel round_up() instead of custom _RND4().
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/core/rtw_cmd.c | 2 +-
drivers/staging/r8188eu/include/osdep_service.h | 8 --------
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c
index ecd0488c439b..4977a0b99415 100644
--- a/drivers/staging/r8188eu/core/rtw_cmd.c
+++ b/drivers/staging/r8188eu/core/rtw_cmd.c
@@ -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);
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index 56e5cbfec1f1..388c22751d09 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] staging: r8188eu: use round_up() instead of _RND8()
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-06 6:18 ` [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4() Michael Straube
2022-04-06 6:18 ` [PATCH 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
@ 2022-04-06 6:18 ` Michael Straube
2022-04-06 6:18 ` [PATCH 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
2022-04-06 6:18 ` [PATCH 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel round_up() instead of custom _RND8().
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 6 +++---
drivers/staging/r8188eu/include/osdep_service.h | 8 --------
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
index 87095eff107b..e00791efccc8 100644
--- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
+++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c
@@ -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)
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index 388c22751d09..ff44c4a37b9d 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] staging: r8188eu: use round_up() instead of _RND128()
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
` (2 preceding siblings ...)
2022-04-06 6:18 ` [PATCH 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
@ 2022-04-06 6:18 ` Michael Straube
2022-04-06 6:18 ` [PATCH 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel round_up() instead of custom _RND128().
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/hal/usb_ops_linux.c | 2 +-
drivers/staging/r8188eu/include/osdep_service.h | 8 --------
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
index 6a65dcf57112..d5e674542a78 100644
--- a/drivers/staging/r8188eu/hal/usb_ops_linux.c
+++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c
@@ -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)
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index ff44c4a37b9d..f6c55f6c9e1a 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
` (3 preceding siblings ...)
2022-04-06 6:18 ` [PATCH 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
@ 2022-04-06 6:18 ` Michael Straube
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 6:18 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Remove the unused macro _RND() and the unused functions _RND256(),
_RND512() from osdep_service.h.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
.../staging/r8188eu/include/osdep_service.h | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h
index f6c55f6c9e1a..f1f3e3ba5377 100644
--- a/drivers/staging/r8188eu/include/osdep_service.h
+++ b/drivers/staging/r8188eu/include/osdep_service.h
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4()
2022-04-06 6:18 ` [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4() Michael Straube
@ 2022-04-06 9:54 ` Joe Perches
2022-04-06 14:56 ` Michael Straube
0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2022-04-06 9:54 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel
On Wed, 2022-04-06 at 08:18 +0200, Michael Straube wrote:
> Use in-kernel round_up() instead of custom RND4().
[]
> diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
[]
> @@ -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...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4()
2022-04-06 9:54 ` Joe Perches
@ 2022-04-06 14:56 ` Michael Straube
0 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2022-04-06 14:56 UTC (permalink / raw)
To: Joe Perches, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel
On 4/6/22 11:54, Joe Perches wrote:
> On Wed, 2022-04-06 at 08:18 +0200, Michael Straube wrote:
>> Use in-kernel round_up() instead of custom RND4().
> []
>> diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
> []
>> @@ -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...
Sounds reasonable, I'll send v2 soon.
Thanks,
Michael
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-04-06 16:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 6:18 [PATCH 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-06 6:18 ` [PATCH 1/5] staging: r8188eu: use round_up() instead of RND4() Michael Straube
2022-04-06 9:54 ` Joe Perches
2022-04-06 14:56 ` Michael Straube
2022-04-06 6:18 ` [PATCH 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
2022-04-06 6:18 ` [PATCH 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
2022-04-06 6:18 ` [PATCH 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
2022-04-06 6:18 ` [PATCH 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).