linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup
@ 2025-11-25 11:20 Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 1/5] staging: rtl8723bs: remove unused registry and BSSID offset macros Navaneeth K
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	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>.

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(-)

-- 
2.43.0


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

* [PATCH v2 1/5] staging: rtl8723bs: remove unused registry and BSSID offset macros
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
@ 2025-11-25 11:20 ` Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 2/5] staging: rtl8723bs: use standard offsetof in cfg80211 operations Navaneeth K
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	Navaneeth K

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.

Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
 drivers/staging/rtl8723bs/include/drv_types.h | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index dd9018aa4ee5..f86180dc350c 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -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)
-- 
2.43.0


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

* [PATCH v2 2/5] staging: rtl8723bs: use standard offsetof in cfg80211 operations
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 1/5] staging: rtl8723bs: remove unused registry and BSSID offset macros Navaneeth K
@ 2025-11-25 11:20 ` Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 3/5] staging: rtl8723bs: remove dead commented code from odm.c Navaneeth K
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	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.

Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
 drivers/staging/rtl8723bs/include/basic_types.h   | 1 +
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index 1c2da18e6210..16b270fe0203 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -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)
 
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 315bab373729..60edeae1cffe 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -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;
-- 
2.43.0


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

* [PATCH v2 3/5] staging: rtl8723bs: remove dead commented code from odm.c
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 1/5] staging: rtl8723bs: remove unused registry and BSSID offset macros Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 2/5] staging: rtl8723bs: use standard offsetof in cfg80211 operations Navaneeth K
@ 2025-11-25 11:20 ` Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 4/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in rtw_mlme_ext.c Navaneeth K
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	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.

Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
 drivers/staging/rtl8723bs/hal/odm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c
index 4b36af47f680..639b6da2302b 100644
--- a/drivers/staging/rtl8723bs/hal/odm.c
+++ b/drivers/staging/rtl8723bs/hal/odm.c
@@ -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;
-- 
2.43.0


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

* [PATCH v2 4/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in rtw_mlme_ext.c
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
                   ` (2 preceding siblings ...)
  2025-11-25 11:20 ` [PATCH v2 3/5] staging: rtl8723bs: remove dead commented code from odm.c Navaneeth K
@ 2025-11-25 11:20 ` Navaneeth K
  2025-11-25 11:20 ` [PATCH v2 5/5] staging: rtl8723bs: remove custom FIELD_OFFSET macro Navaneeth K
  2025-11-25 12:10 ` [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Dan Carpenter
  5 siblings, 0 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	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.

Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index a897c433d2b0..9372b997fc23 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -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 */
-- 
2.43.0


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

* [PATCH v2 5/5] staging: rtl8723bs: remove custom FIELD_OFFSET macro
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
                   ` (3 preceding siblings ...)
  2025-11-25 11:20 ` [PATCH v2 4/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in rtw_mlme_ext.c Navaneeth K
@ 2025-11-25 11:20 ` Navaneeth K
  2025-11-25 12:10 ` [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Dan Carpenter
  5 siblings, 0 replies; 7+ messages in thread
From: Navaneeth K @ 2025-11-25 11:20 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, linux-kernel, dan.carpenter, david.laight,
	Navaneeth K

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

Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
 drivers/staging/rtl8723bs/include/basic_types.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/include/basic_types.h b/drivers/staging/rtl8723bs/include/basic_types.h
index 16b270fe0203..8adb95f9f1e5 100644
--- a/drivers/staging/rtl8723bs/include/basic_types.h
+++ b/drivers/staging/rtl8723bs/include/basic_types.h
@@ -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
 
-- 
2.43.0


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

* Re: [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup
  2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
                   ` (4 preceding siblings ...)
  2025-11-25 11:20 ` [PATCH v2 5/5] staging: rtl8723bs: remove custom FIELD_OFFSET macro Navaneeth K
@ 2025-11-25 12:10 ` Dan Carpenter
  5 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2025-11-25 12:10 UTC (permalink / raw)
  To: Navaneeth K; +Cc: gregkh, linux-staging, linux-kernel, david.laight

On Tue, Nov 25, 2025 at 11:20:54AM +0000, Navaneeth K wrote:
> 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.
> 

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter


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

end of thread, other threads:[~2025-11-25 12:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 11:20 [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Navaneeth K
2025-11-25 11:20 ` [PATCH v2 1/5] staging: rtl8723bs: remove unused registry and BSSID offset macros Navaneeth K
2025-11-25 11:20 ` [PATCH v2 2/5] staging: rtl8723bs: use standard offsetof in cfg80211 operations Navaneeth K
2025-11-25 11:20 ` [PATCH v2 3/5] staging: rtl8723bs: remove dead commented code from odm.c Navaneeth K
2025-11-25 11:20 ` [PATCH v2 4/5] staging: rtl8723bs: replace FIELD_OFFSET usage with offsetof in rtw_mlme_ext.c Navaneeth K
2025-11-25 11:20 ` [PATCH v2 5/5] staging: rtl8723bs: remove custom FIELD_OFFSET macro Navaneeth K
2025-11-25 12:10 ` [PATCH v2 0/5] staging: rtl8723bs: FIELD_OFFSET macro cleanup Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).