linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Navaneeth K <knavaneeth786@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	dan.carpenter@linaro.org, david.laight@runbox.com,
	Navaneeth K <knavaneeth786@gmail.com>
Subject: [PATCH v2 2/5] staging: rtl8723bs: use standard offsetof in cfg80211 operations
Date: Tue, 25 Nov 2025 11:20:56 +0000	[thread overview]
Message-ID: <20251125112059.16913-3-knavaneeth786@gmail.com> (raw)
In-Reply-To: <20251125112059.16913-1-knavaneeth786@gmail.com>

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


  parent reply	other threads:[~2025-11-25 11:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20251125112059.16913-3-knavaneeth786@gmail.com \
    --to=knavaneeth786@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=david.laight@runbox.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;
as well as URLs for NNTP newsgroup(s).