staging: rtl8723bs: remove custom FIELD_OFFSET macro and dead code
cover staging: rtl8723bs: remove custom FIELD_OFFSET macro and dead code
This series performs cleanup on the rtl8723bs staging driver to align with kernel coding standards.
The driver defined a custom macro FIELD_OFFSET which duplicated the functionality of the standard offsetof() macro. This series replaces all usages of the custom macro with the standard one and removes the redundant definition.
Additionally, this series removes dead commented-out code in odm.c that referenced unsupported chips (RTL8723A/RTL8188E).
All patches checkpatch clean.
Navaneeth K (5):
staging: rtl8723bs: remove custom FIELD_OFFSET macro
staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
staging: rtl8723bs: use standard offsetof in cfg80211 operations
staging: rtl8723bs: remove dead code from odm.c
staging: rtl8723bs: use offsetof in rtw_mlme_ext.c
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723bs/hal/odm.c | 4 ---- drivers/staging/rtl8723bs/include/basic_types.h | 3 +-- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- 5 files changed, 7 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/5 staging: rtl8723bs: remove custom FIELD_OFFSET macro
The driver defined a custom macro FIELD_OFFSET which duplicates the standard functionality of the kernel's offsetof() macro.
Remove the custom definition to clean up the code and rely on standard kernel macros.
--- drivers/staging/rtl8723bs/include/basic_types.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/basic_types.h +1 -2
@@ -12,8 +12,7 @@#define FAIL (-1)#include <linux/types.h> - -#define FIELD_OFFSET (s, field) ((__kernel_ssize_t)&((s *)(0))->field) +#include <linux/stddef.h> #define SIZE_PTR __kernel_size_t#define SSIZE_PTR __kernel_ssize_t
Signature · 1 line
2.43.0
PATCH 2/5 staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
In reply to Navaneeth KReplace usage of the custom FIELD_OFFSET macro with the standard offsetof() macro in drv_types.h. This improves code readability and standardization.
--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/include/drv_types.h +2 -2
@@ -173,9 +173,9 @@ struct registry_priv {/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(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_OFT (field) ((u32)offsetof(struct wlan_bssid_ex, field))#define BSSID_SZ (field) sizeof(((struct wlan_bssid_ex *) 0)->field)#include <drv_types_sdio.h>
Signature · 1 line
2.43.0
Re: [PATCH 2/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
Quoted 14 lines · Navaneeth K
Replace usage of the custom
FIELD_OFFSETmacro with the standardoffsetof()macro indrv_types.h. This improves code readability and standardization.Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/drv_types.h +0
-0
drivers/staging/rtl8723bs/include/drv_types.h struct registry_priv { · line 176
Quoted 5 lines
drivers/staging/rtl8723bs/include/drv_types.h +1
-1@@ -173,9 +173,9 @@ struct registry_priv {/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(struct registry_priv, field))
These casts to u32 are bogus garbage. Delete them.
regards,
dan carpenter
Re: [PATCH 2/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
Quoted 17 lines · On Mon, 24 Nov 2025 11:08:35 +0300 Dan Carpenter <[email protected]>…
Quoted 16 lines · Navaneeth K
Replace usage of the custom
FIELD_OFFSETmacro with the standardoffsetof()macro indrv_types.h. This improves code readability and standardization.Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/drv_types.h +0
-0@@ -173,9 +173,9 @@ struct registry_priv {
Quoted 5 lines
drivers/staging/rtl8723bs/include/drv_types.h struct registry_priv { · line 176
Quoted 3 lines
drivers/staging/rtl8723bs/include/drv_types.h +1
-1/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(struct registry_priv, field))These casts to u32 are bogus garbage. Delete them.
Dunno - they might be needed (or have been needed) to stop min() complaining about type mismatch.
They can also stop expressions being evaluated as 64bit (on 64bit) which may reduce code size.
But that is a bit subtle...
David
Quoted 6 lines
regards,
dan carpenter
Re: [PATCH 2/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
Quoted 26 lines · david laight
Quoted 17 lines · On Mon, 24 Nov 2025 11:08:35 +0300 Dan Carpenter <[email protected]>…
Quoted 16 lines · Navaneeth K
Replace usage of the custom
FIELD_OFFSETmacro with the standardoffsetof()macro indrv_types.h. This improves code readability and standardization.Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/drv_types.h +0
-0@@ -173,9 +173,9 @@ struct registry_priv {Quoted 5 lines
drivers/staging/rtl8723bs/include/drv_types.h struct registry_priv { · line 176
Quoted 3 lines
drivers/staging/rtl8723bs/include/drv_types.h +1
-1/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(struct registry_priv, field))These casts to u32 are bogus garbage. Delete them.
Quoted 5 lines
Dunno - they might be needed (or have been needed) to stop
min()complaining about type mismatch.
They can also stop expressions being evaluated as 64bit (on 64bit) which may reduce code size.
But that is a bit subtle...
Actually the macros are unused. Just delete them entirely.
regards,
dan carpenter
Re: [PATCH 2/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
Quoted 27 lines · On Mon, 24 Nov 2025 12:45:46 +0300 Dan Carpenter <[email protected]>…
Quoted 26 lines · david laight
Quoted 22 lines · On Mon, 24 Nov 2025 11:08:35 +0300 Dan Carpenter <[email protected]>…
Quoted 14 lines · Navaneeth K
Replace usage of the custom
FIELD_OFFSETmacro with the standardoffsetof()macro indrv_types.h. This improves code readability and standardization.Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/drv_types.h +0
-0drivers/staging/rtl8723bs/include/drv_types.h struct registry_priv { · line 176
Quoted 5 lines
drivers/staging/rtl8723bs/include/drv_types.h +1
-1@@ -173,9 +173,9 @@ struct registry_priv {/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(struct registry_priv, field))These casts to u32 are bogus garbage. Delete them.
Quoted 7 lines
Quoted 5 lines
Dunno - they might be needed (or have been needed) to stop
min()complaining about type mismatch.
They can also stop expressions being evaluated as 64bit (on 64bit) which may reduce code size.
But that is a bit subtle...Actually the macros are unused. Just delete them entirely.
Sounds good to me :-)
Quoted 4 lines
regards,
dan carpenter
Re: [PATCH 2/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof
Hi Dan, Hi David,
Thanks for the clarification.
I’ll remove the unused macro entirely in v2 instead of adjusting the cast.
Regards,
Navaneeth K
Quoted 39 lines · david laight
Quoted 25 lines · On Mon, 24 Nov 2025 12:45:46 +0300 Dan Carpenter <[email protected]>…
Quoted 24 lines · david laight
Quoted 21 lines · On Mon, 24 Nov 2025 11:08:35 +0300 Dan Carpenter <[email protected]>…
Quoted 14 lines · Navaneeth K
Replace usage of the custom
FIELD_OFFSETmacro with the standardoffsetof()macro indrv_types.h. This improves code readability and standardization.Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/include/drv_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/include/drv_types.h +0
-0drivers/staging/rtl8723bs/include/drv_types.h struct registry_priv { · line 176
Quoted 5 lines
drivers/staging/rtl8723bs/include/drv_types.h +1
-1@@ -173,9 +173,9 @@ struct registry_priv {/* For registry parameters */ -#define RGTRY_OFT (field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_OFT (field) ((u32)offsetof(struct registry_priv, field))These casts to u32 are bogus garbage. Delete them.
Quoted 6 lines
Quoted 5 lines
Dunno - they might be needed (or have been needed) to stop
min()complaining about type mismatch.
They can also stop expressions being evaluated as 64bit (on 64bit) which may reduce code size.
But that is a bit subtle...Actually the macros are unused. Just delete them entirely.
Sounds good to me :-)
Quoted 3 lines
regards,
dan carpenter
PATCH 3/5 staging: rtl8723bs: use standard offsetof in cfg80211 operations
In reply to Navaneeth KReplace usage of the custom FIELD_OFFSET macro with the standard offsetof() macro in ioctl_cfg80211.c.
This resolves coding style issues and standardizes memory offset calculations.
--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -1
@@ -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
PATCH 4/5 staging: rtl8723bs: remove dead code from odm.c
In reply to Navaneeth KRemove commented-out code references to RTL8723A and RTL8188E which are not supported by this driver. This cleans up the source file and improves readability.
--- drivers/staging/rtl8723bs/hal/odm.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/staging/rtl8723bs/hal/odm.c +0 -4
@@ -610,10 +610,6 @@ void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)/* 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
Signature · 1 line
2.43.0
Re: [PATCH 4/5] staging: rtl8723bs: remove dead code from odm.c
Quoted 14 lines · Navaneeth K
Remove commented-out code references to RTL8723A and RTL8188E which are not supported by this driver. This cleans up the source file and improves readability.
Signed-off-by Navaneeth K <[email protected]>--- drivers/staging/rtl8723bs/hal/odm.c | 4 ---- 1 file changed, 4 deletions(-)drivers/staging/rtl8723bs/hal/odm.c +0
-0
drivers/staging/rtl8723bs/hal/odm.c void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm) · line 613
Quoted 8 lines
drivers/staging/rtl8723bs/hal/odm.c +0
-4@@ -610,10 +610,6 @@ void ODM_DMWatchdog(struct dm_odm_t *pDM_Odm)/* 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))) */ -/* */ ) {
When you're breaking things up into One Thing Per Patch, these bits were part of the condition so it's allowed to move the ") {" to the earlier line. It's part of fixing the condition.
regards,
dan carpenter
Quoted 5 lines
drivers/staging/rtl8723bs/hal/odm.c +0
-0odm_DIGbyRSSI_LPS (pDM_Odm); }else Signature · 1 line
2.43.0
PATCH 5/5 staging: rtl8723bs: use offsetof in rtw_mlme_ext.c
In reply to Navaneeth KReplace the custom FIELD_OFFSET macro with the standard offsetof() macro during the BSSID copy operation.
--- 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
@@ -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