Skip to contentSkip to conversation

staging: rtl8723bs: FIELD_OFFSET macro cleanup

PATCH In review Navaneeth K 2 participants 7 messages Nov 25, 2025 Staging

lore
Share & tools
lore
#0 lore raw

v2 cover staging: rtl8723bs: FIELD_OFFSET macro cleanup

This series cleans up the rtl8723bs driver by removing the custom FIELD_OFFSET macro and replacing its usages with the standard offsetof() from <linux/stddef.h>.

Changes in v2:
- Split the series for proper bisectability: the FIELD_OFFSET macro definition is now removed in Patch 5 (after all usages are converted), rather than in Patch 1.
- Patch 1: Now only removes unused RGTRY_OFT, RGTRY_SZ, BSSID_OFT, and BSSID_SZ macros (dead code not used anywhere in the driver).
- Patch 2: Split long line to fit within 100 columns. Also added <linux/stddef.h> include to basic_types.h to support offsetof usage.
- Patch 3: Fixed brace formatting issue caused by removing commented code. Removed unnecessary outer parentheses, moved the inline comment to its own line, and added braces to the else branch for consistent style.
- Patch 5 (NEW): Remove FIELD_OFFSET definition now that it's unused.

Navaneeth K (5):
staging: rtl8723bs: remove unused registry and BSSID offset macros
staging: rtl8723bs: use standard offsetof in cfg80211 operations
staging: rtl8723bs: remove dead commented code from odm.c
staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in
rtw_mlme_ext.c
staging: rtl8723bs: remove custom FIELD_OFFSET macro

 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c     |  4 ++--
 drivers/staging/rtl8723bs/hal/odm.c               | 13 +++++--------
 drivers/staging/rtl8723bs/include/basic_types.h   |  3 +--
 drivers/staging/rtl8723bs/include/drv_types.h     |  7 -------
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  3 ++-
 5 files changed, 10 insertions(+), 20 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/5 staging: rtl8723bs: remove unused registry and BSSID offset macros

The RGTRY_OFT, RGTRY_SZ, BSSID_OFT, and BSSID_SZ macros are defined but never used anywhere in the driver. Remove these dead macro definitions to clean up the code.

---
 drivers/staging/rtl8723bs/include/drv_types.h | 7 -------
 1 file changed, 7 deletions(-)
drivers/staging/rtl8723bs/include/drv_types.h +0 -7
index dd9018aa4ee5..f86180dc350c 100644
@@ -171,13 +171,6 @@ struct registry_priv {
 	u8 hiq_filter;
 };
 
-
-/* For registry parameters */
-#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
-#define RGTRY_SZ(field)   sizeof(((struct registry_priv *)0)->field)
-#define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
-#define BSSID_SZ(field)   sizeof(((struct wlan_bssid_ex *) 0)->field)
-
 #include <drv_types_sdio.h>
 
 #define GET_PRIMARY_ADAPTER(padapter) (((struct adapter *)padapter)->dvobj->if1)
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/5 staging: rtl8723bs: use standard offsetof in cfg80211 operations

In reply to Navaneeth K

Replace usage of the custom FIELD_OFFSET macro with the standard offsetof() macro in ioctl_cfg80211.c. This improves code readability and uses the kernel's standard mechanism.

Also include <linux/stddef.h> in basic_types.h to ensure offsetof() is available for this and future conversions.

---
 drivers/staging/rtl8723bs/include/basic_types.h   | 1 +
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/include/basic_types.h +1 -0
index 1c2da18e6210..16b270fe0203 100644
@@ -12,6 +12,7 @@
 #define FAIL	(-1)
 
 #include <linux/types.h>
+#include <linux/stddef.h>
 
 #define FIELD_OFFSET(s, field)	((__kernel_ssize_t)&((s *)(0))->field)
 
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -1
index 315bab373729..60edeae1cffe 100644
@@ -1712,7 +1712,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
 
 		if (wep_key_len > 0) {
 			wep_key_len = wep_key_len <= 5 ? 5 : 13;
-			wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material);
+			wep_total_len = wep_key_len +
+				offsetof(struct ndis_802_11_wep, key_material);
 			pwep = rtw_malloc(wep_total_len);
 			if (!pwep) {
 				ret = -ENOMEM;
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/5 staging: rtl8723bs: remove dead commented code from odm.c

In reply to Navaneeth K

Remove obsolete commented-out code that references unsupported chip variants (ODM_RTL8723A, ODM_RTL8188E). This code has been dead since the driver was added to staging.

Also fix the resulting formatting by removing the unnecessary outer parentheses and moving the inline comment to its own line.

---
 drivers/staging/rtl8723bs/hal/odm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/staging/rtl8723bs/hal/odm.c +5 -8
index 4b36af47f680..639b6da2302b 100644
@@ -609,15 +609,12 @@ void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)
 	/* 8723A or 8189ES platform */
 	/* NeilChen--2012--08--24-- */
 	/* Fix Leave LPS issue */
-	if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) /*  in LPS mode */
-		/*  */
-		/* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */
-		/* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface  == ODM_ITRF_SDIO))) */
-		/*  */
-	) {
-			odm_DIGbyRSSI_LPS(pDM_Odm);
-	} else
+	if (adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) {
+		/* in LPS mode */
+		odm_DIGbyRSSI_LPS(pDM_Odm);
+	} else {
 		odm_DIG(pDM_Odm);
+	}
 
 	{
 		struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/5 staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in rtw_mlme_ext.c

In reply to Navaneeth K

Replace usage of the custom FIELD_OFFSET macro with the standard offsetof() macro in rtw_mlme_ext.c. This improves code readability and uses the kernel's standard mechanism.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +2 -2
index a897c433d2b0..9372b997fc23 100644
@@ -5275,7 +5275,7 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf)
 		/* clear CAM */
 		flush_all_cam_entry(padapter);
 
-		memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, ie_length));
+		memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, ie_length));
 		pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length;
 
 		if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */
@@ -5339,7 +5339,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf)
 	/* pmlmeinfo->assoc_AP_vendor = HT_IOT_PEER_MAX; */
 	pmlmeinfo->VHT_enable = 0;
 
-	memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, ie_length));
+	memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, ie_length));
 	pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length;
 
 	if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/5 staging: rtl8723bs: remove custom FIELD_OFFSET macro

In reply to Navaneeth K

The custom FIELD_OFFSET macro is no longer used in the driver (replaced by standard offsetof). Remove the definition.

---
 drivers/staging/rtl8723bs/include/basic_types.h | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/rtl8723bs/include/basic_types.h +0 -2
index 16b270fe0203..8adb95f9f1e5 100644
@@ -14,8 +14,6 @@
 #include <linux/types.h>
 #include <linux/stddef.h>
 
-#define FIELD_OFFSET(s, field)	((__kernel_ssize_t)&((s *)(0))->field)
-
 #define SIZE_PTR __kernel_size_t
 #define SSIZE_PTR __kernel_ssize_t
 
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#6 lore raw
In reply to Navaneeth K
Quoted 4 lines · Navaneeth K

This series cleans up the rtl8723bs driver by removing the custom FIELD_OFFSET macro and replacing its usages with the standard offsetof() from <linux/stddef.h>.

Quoted 14 lines

Changes in v2:
- Split the series for proper bisectability: the FIELD_OFFSET macro definition is now removed in Patch 5 (after all usages are converted), rather than in Patch 1.
- Patch 1: Now only removes unused RGTRY_OFT, RGTRY_SZ, BSSID_OFT, and BSSID_SZ macros (dead code not used anywhere in the driver).
- Patch 2: Split long line to fit within 100 columns. Also added <linux/stddef.h> include to basic_types.h to support offsetof usage.
- Patch 3: Fixed brace formatting issue caused by removing commented code. Removed unnecessary outer parentheses, moved the inline comment to its own line, and added braces to the else branch for consistent style.
- Patch 5 (NEW): Remove FIELD_OFFSET definition now that it's unused.

Thanks!

regards,
dan carpenter