* [PATCH v3 0/5] staging: r8188eu: use round_up()
@ 2022-04-07 12:57 Michael Straube
2022-04-07 12:57 ` [PATCH v3 1/5] staging: r8188eu: use PTR_ALIGN() instead of RND4() Michael Straube
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 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()
and PTR_ALIGN() instead of custom _RND* implementations.
Tested on x86_64 with Inter-Tech DMG-02.
v3:
just remove _RND8 in one case
v2:
use PTR_ALIGN in patch 1/5
Michael Straube (5):
staging: r8188eu: use PTR_ALIGN() 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 | 7 +--
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(+), 57 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/5] staging: r8188eu: use PTR_ALIGN() instead of RND4()
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
@ 2022-04-07 12:57 ` Michael Straube
2022-04-07 12:57 ` [PATCH v3 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel PTR_ALIGN() instead of custom RND4().
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
v3: no changes
v2: use PTR_ALIGN
drivers/staging/r8188eu/core/rtw_security.c | 6 +++---
drivers/staging/r8188eu/core/rtw_xmit.c | 7 ++-----
drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 2 +-
drivers/staging/r8188eu/include/osdep_service.h | 1 -
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c
index 2cdcdfd5ca5c..5bba57d18b5f 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 = PTR_ALIGN(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 = PTR_ALIGN(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 = PTR_ALIGN(pframe, 4);
}
}
} else {
diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index aede8ef8b098..029b994e1b71 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 = PTR_ALIGN(payload, 4);
payload = payload + pattrib->hdrlen + pattrib->iv_len;
if ((curfragnum + 1) == pattrib->nr_frags) {
@@ -868,7 +868,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
{
struct pkt_file pktfile;
s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
- size_t addr;
u8 *pframe, *mem_start;
u8 hw_hdr_offset;
struct sta_info *psta;
@@ -985,9 +984,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
break;
}
- addr = (size_t)(pframe);
-
- mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset;
+ mem_start = PTR_ALIGN(pframe, 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..9bd2428514de 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 = PTR_ALIGN(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] 6+ messages in thread
* [PATCH v3 2/5] staging: r8188eu: use round_up() instead of _RND4()
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-07 12:57 ` [PATCH v3 1/5] staging: r8188eu: use PTR_ALIGN() instead of RND4() Michael Straube
@ 2022-04-07 12:57 ` Michael Straube
2022-04-07 12:57 ` [PATCH v3 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 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>
---
v3: no changes
v2: no changes
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 9b53b92c6795..ed092faafb0f 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] 6+ messages in thread
* [PATCH v3 3/5] staging: r8188eu: use round_up() instead of _RND8()
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-07 12:57 ` [PATCH v3 1/5] staging: r8188eu: use PTR_ALIGN() instead of RND4() Michael Straube
2022-04-07 12:57 ` [PATCH v3 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
@ 2022-04-07 12:57 ` Michael Straube
2022-04-07 12:57 ` [PATCH v3 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
2022-04-07 12:57 ` [PATCH v3 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 UTC (permalink / raw)
To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube
Use in-kernel round_up() instead of custom _RND8().
Just remove _RND8 where it is not necessary to round up.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
v3: just remove _RND8 in one case
v2: no changes
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 9bd2428514de..bdfa51949289 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 (pbuf + len > 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] 6+ messages in thread
* [PATCH v3 4/5] staging: r8188eu: use round_up() instead of _RND128()
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
` (2 preceding siblings ...)
2022-04-07 12:57 ` [PATCH v3 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
@ 2022-04-07 12:57 ` Michael Straube
2022-04-07 12:57 ` [PATCH v3 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 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>
---
v3: no changes
v2: no changes
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] 6+ messages in thread
* [PATCH v3 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
` (3 preceding siblings ...)
2022-04-07 12:57 ` [PATCH v3 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
@ 2022-04-07 12:57 ` Michael Straube
4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2022-04-07 12:57 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>
---
v3: no changes
v2: no changes
.../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] 6+ messages in thread
end of thread, other threads:[~2022-04-07 12:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 12:57 [PATCH v3 0/5] staging: r8188eu: use round_up() Michael Straube
2022-04-07 12:57 ` [PATCH v3 1/5] staging: r8188eu: use PTR_ALIGN() instead of RND4() Michael Straube
2022-04-07 12:57 ` [PATCH v3 2/5] staging: r8188eu: use round_up() instead of _RND4() Michael Straube
2022-04-07 12:57 ` [PATCH v3 3/5] staging: r8188eu: use round_up() instead of _RND8() Michael Straube
2022-04-07 12:57 ` [PATCH v3 4/5] staging: r8188eu: use round_up() instead of _RND128() Michael Straube
2022-04-07 12:57 ` [PATCH v3 5/5] staging: r8188eu: remove unused _RND* from osdep_service.h Michael Straube
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.