[PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment

From: Ashmit Kumar

Date: Sun Oct 18 2026 - 12:50:00 EST


The driver open-codes pointer alignment using round_up() with the
custom SIZE_PTR macro, or performs manual arithmetic on pointer
addresses.

Replace these open-coded pointer alignments with the standard
PTR_ALIGN() macro, and remove the now unused temporary variable
addr in rtw_xmitframe_coalesce().

Signed-off-by: Ashmit Kumar <work.ashmitkumar@xxxxxxxxx>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 6 +++---
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 3 +--
drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 ++------
3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index ae64823afb8b..e9043104544c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -92,7 +92,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
arc4_crypt(ctx, payload + length, crc.f1, 4);

pframe += pxmitpriv->frag_len;
- pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
+ pframe = PTR_ALIGN(pframe, 4);
}
}
}
@@ -492,7 +492,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
arc4_crypt(ctx, payload + length, crc.f1, 4);

pframe += pxmitpriv->frag_len;
- pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
+ pframe = PTR_ALIGN(pframe, 4);
}
}
return res;
@@ -977,7 +977,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)

aes_cipher(prwskey, pattrib->hdrlen, pframe, length);
pframe += pxmitpriv->frag_len;
- pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
+ pframe = PTR_ALIGN(pframe, 4);
}
}
return res;
diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index ba7e53140bdd..a10672c11643 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -56,8 +56,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv)
if (!pstapriv->pallocated_stainfo_buf)
return _FAIL;

- pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
- ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf) & 3);
+ pstapriv->pstainfo_buf = PTR_ALIGN(pstapriv->pallocated_stainfo_buf, 4);

INIT_LIST_HEAD(&pstapriv->free_sta_queue.queue);
spin_lock_init(&pstapriv->free_sta_queue.lock);
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 364de3c8d148..aded0cb27be9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -853,7 +853,7 @@ static int xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
payload = pframe;

for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
- payload = (u8 *)round_up((SIZE_PTR)(payload), 4);
+ payload = PTR_ALIGN(payload, 4);
payload = payload + pattrib->hdrlen + pattrib->iv_len;

if ((curfragnum + 1) == pattrib->nr_frags) {
@@ -1066,8 +1066,6 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct

s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;

- SIZE_PTR addr;
-
u8 *pframe, *mem_start;
u8 hw_hdr_offset;

@@ -1162,9 +1160,7 @@ int rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
break;
}

- addr = (SIZE_PTR)(pframe);
-
- mem_start = (unsigned char *)round_up(addr, 4) + hw_hdr_offset;
+ mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset;
memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
}

--
2.43.0