Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: rtl8723bs: clean up SIZE_PTR usage and remove custom macro
@ 2026-10-18 16:43 Ashmit Kumar
  2026-10-18 16:44 ` [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment Ashmit Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ashmit Kumar @ 2026-10-18 16:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Ashmit Kumar

This patch series cleans up the custom macro SIZE_PTR (__kernel_size_t)
across the rtl8723bs driver as part of addressing the TODO item to
"convert any remaining unusual variable types".

Instead of a mechanical substitution, each occurrence has been converted
to its idiomatic kernel equivalent:
1. Replace open-coded pointer alignments with the standard PTR_ALIGN()
   macro, removing an unused variable left behind.
2. Remove redundant pointer-to-integer casts where pointer arithmetic or
   pointer arguments are already sufficient.
3. Replace the remaining pointer-to-integer address casts with uintptr_t,
   use size_t for alignment offsets, and delete the custom SIZE_PTR macro
   definition entirely.

Ashmit Kumar (3):
  staging: rtl8723bs: use PTR_ALIGN() for pointer alignment
  staging: rtl8723bs: remove unnecessary pointer-to-integer casts
  staging: rtl8723bs: replace SIZE_PTR with uintptr_t and remove
    definition

 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c   |  8 ++++----
 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 ++------
 drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c  | 11 ++++++-----
 drivers/staging/rtl8723bs/hal/sdio_ops.c        |  6 +++---
 drivers/staging/rtl8723bs/include/basic_types.h |  2 --
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c   |  2 +-
 8 files changed, 20 insertions(+), 26 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment
  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
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Ashmit Kumar @ 2026-10-18 16:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Ashmit Kumar

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] staging: rtl8723bs: remove unnecessary pointer-to-integer casts
  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 ` [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment Ashmit Kumar
@ 2026-10-18 16:44 ` Ashmit Kumar
  2026-10-18 16:44 ` [PATCH 3/3] staging: rtl8723bs: replace SIZE_PTR with uintptr_t and remove definition Ashmit Kumar
  2 siblings, 0 replies; 4+ messages in thread
From: Ashmit Kumar @ 2026-10-18 16:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Ashmit Kumar

The pointer pframe in rtw_mlme_ext.c is cast to (SIZE_PTR) before
being passed as an argument or evaluated in expressions where it is
already a pointer type. In xmit_linux.c, the buffer length was
calculated using unnecessary casts:
(SIZE_PTR)pfile->cur_addr - (SIZE_PTR)pfile->buf_start
where standard pointer subtraction pfile->cur_addr - pfile->buf_start
yields ptrdiff_t directly without any casting.

Remove these redundant casts to simplify the code and use standard C
pointer arithmetic.

Signed-off-by: Ashmit Kumar <work.ashmitkumar@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++----
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 511eccf5b5a3..9e89d4a0392d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -707,8 +707,8 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame)
 		offset = 4;
 	}
 
-	algorithm = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset));
-	seq	= le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2));
+	algorithm = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset));
+	seq	= le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 2));
 
 	if (auth_mode == 2 &&
 			psecuritypriv->dot11_privacy_algrthm != _WEP40_ &&
@@ -856,8 +856,8 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram
 
 	offset = (GetPrivacy(pframe)) ? 4 : 0;
 
-	seq	= le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2));
-	status	= le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 4));
+	seq	= le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 2));
+	status	= le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + offset + 4));
 
 	if (status != 0) {
 		if (status == 13) { /*  pmlmeinfo->auth_algo == dot11_auth_algrthm_auto) */
diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
index 6ee2a1f29aa4..91ab0f8bcb69 100644
--- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c
@@ -9,7 +9,7 @@
 
 unsigned int rtw_remainder_len(struct pkt_file *pfile)
 {
-	return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
+	return pfile->buf_len - (pfile->cur_addr - pfile->buf_start);
 }
 
 void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] staging: rtl8723bs: replace SIZE_PTR with uintptr_t and remove definition
  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 ` [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment Ashmit Kumar
  2026-10-18 16:44 ` [PATCH 2/3] staging: rtl8723bs: remove unnecessary pointer-to-integer casts Ashmit Kumar
@ 2026-10-18 16:44 ` Ashmit Kumar
  2 siblings, 0 replies; 4+ messages in thread
From: Ashmit Kumar @ 2026-10-18 16:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, Ashmit Kumar

The driver defines a custom macro SIZE_PTR as __kernel_size_t, which is
used when casting pointer values to integers to calculate alignment
offsets.

Replace the remaining casts of pointers to integers in rtl8723bs_recv.c
and sdio_ops.c with uintptr_t, use size_t for the alignment variable,
and remove the SIZE_PTR macro definition from basic_types.h.

Signed-off-by: Ashmit Kumar <work.ashmitkumar@gmail.com>
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c  | 11 ++++++-----
 drivers/staging/rtl8723bs/hal/sdio_ops.c        |  6 +++---
 drivers/staging/rtl8723bs/include/basic_types.h |  2 --
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
index a62b845c69f9..f3f9c2699c68 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c
@@ -295,7 +295,8 @@ static void rtl8723bs_recv_tasklet(struct tasklet_struct *t)
 
 				pkt_copy->dev = padapter->pnetdev;
 				precvframe->u.hdr.pkt = pkt_copy;
-				skb_reserve(pkt_copy, 8 - ((SIZE_PTR)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */
+				/* force pkt_copy->data at 8-byte alignment address */
+				skb_reserve(pkt_copy, 8 - ((uintptr_t)(pkt_copy->data) & 7));
 				skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */
 				memcpy(pkt_copy->data, (ptr + rx_report_sz + pattrib->shift_sz), skb_len);
 				precvframe->u.hdr.rx_head = pkt_copy->head;
@@ -390,15 +391,15 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter)
 		initrecvbuf(precvbuf, padapter);
 
 		if (!precvbuf->pskb) {
-			SIZE_PTR tmpaddr = 0;
-			SIZE_PTR alignment = 0;
+			uintptr_t tmpaddr = 0;
+			size_t alignment = 0;
 
 			precvbuf->pskb = __dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_ATOMIC);
 			if (precvbuf->pskb) {
 				precvbuf->pskb->dev = padapter->pnetdev;
 
-				tmpaddr = (SIZE_PTR)precvbuf->pskb->data;
-				alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
+				tmpaddr = (uintptr_t)precvbuf->pskb->data;
+				alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
 				skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
 			}
 		}
diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c
index c12f670922d5..9cc5c651f35a 100644
--- a/drivers/staging/rtl8723bs/hal/sdio_ops.c
+++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c
@@ -653,8 +653,8 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)
 
 	/* 3 2. alloc skb */
 	if (!recvbuf->pskb) {
-		SIZE_PTR tmpaddr = 0;
-		SIZE_PTR alignment = 0;
+		uintptr_t tmpaddr = 0;
+		size_t alignment = 0;
 
 		recvbuf->pskb = __dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_ATOMIC);
 		if (!recvbuf->pskb)
@@ -662,7 +662,7 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)
 
 		recvbuf->pskb->dev = adapter->pnetdev;
 
-		tmpaddr = (SIZE_PTR)recvbuf->pskb->data;
+		tmpaddr = (uintptr_t)recvbuf->pskb->data;
 		alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
 		skb_reserve(recvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment));
 	}
diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index d2436459cff6..c3947e61ec22 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -13,8 +13,6 @@
 #include <linux/types.h>
 #include <linux/stddef.h>
 
-#define SIZE_PTR __kernel_size_t
-
 /* port from fw by thomas */
 /*  TODO: Belows are Sync from SD7-Driver. It is necessary to check correctness */
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-18 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/3] staging: rtl8723bs: use PTR_ALIGN() for pointer alignment Ashmit Kumar
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox