From: Ashmit Kumar <work.ashmitkumar@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Ashmit Kumar <work.ashmitkumar@gmail.com>
Subject: [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment
Date: Sun, 18 Oct 2026 16:44:00 +0000 [thread overview]
Message-ID: <20261018164403.14921-2-work.ashmitkumar@gmail.com> (raw)
In-Reply-To: <20261018164403.14921-1-work.ashmitkumar@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2026-10-18 16:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 16:43 [PATCH 0/3] staging: rtl8723bs: clean up SIZE_PTR usage and remove custom macro Ashmit Kumar
2026-10-18 16:44 ` Ashmit Kumar [this message]
2026-10-18 16:44 ` [PATCH 2/3] staging: rtl8723bs: remove unnecessary pointer-to-integer casts Ashmit Kumar
2026-10-18 16:44 ` [PATCH 3/3] staging: rtl8723bs: replace SIZE_PTR with uintptr_t and remove definition Ashmit Kumar
2026-10-19 7:16 ` [PATCH 0/3] staging: rtl8723bs: clean up SIZE_PTR usage and remove custom macro Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018164403.14921-2-work.ashmitkumar@gmail.com \
--to=work.ashmitkumar@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox