staging: rtl8712: Replace FIELD_OFFSET() with offsetof()

Use the existing offsetof() macro instead of duplicating code.

Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
Link: https://lore.kernel.org/r/20200701214420.5566-2-mukadr@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Mauro Dreissig 2020-07-01 18:44:19 -03:00 committed by Greg Kroah-Hartman
parent bd7a168a02
commit 2becc421c9
3 changed files with 4 additions and 5 deletions

View File

@ -21,7 +21,6 @@
#define SIZE_T __kernel_size_t
#define sint signed int
#define FIELD_OFFSET(s, field) ((addr_t)&((s *)(0))->field)
/* Should we extend this to be host_addr_t and target_addr_t for case:
* host : x86_64

View File

@ -133,7 +133,7 @@ static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv))
return _FAIL;
/* check fw_sz & image_fw_sz */
fwhdrsz = FIELD_OFFSET(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz;
fwhdrsz = offsetof(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz;
fw_sz = fwhdrsz + pfwhdr->img_IMEM_size + pfwhdr->img_SRAM_size +
pfwhdr->dmem_size;
if (fw_sz != ulfilelength)
@ -173,7 +173,7 @@ static u8 rtl8712_dl_fw(struct _adapter *adapter)
txdesc = (struct tx_desc *)(tmpchar + FWBUFF_ALIGN_SZ -
((addr_t)(tmpchar) & (FWBUFF_ALIGN_SZ - 1)));
payload = (u8 *)(txdesc) + txdscp_sz;
ptr = (u8 *)mappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) +
ptr = (u8 *)mappedfw + offsetof(struct fw_hdr, fwpriv) +
fwhdr.fw_priv_sz;
/* Download FirmWare */
/* 1. determine IMEM code size and Load IMEM Code Section */

View File

@ -407,7 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
return -ENOMEM;
pwep->KeyLength = wep_key_len;
pwep->Length = wep_key_len +
FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial);
offsetof(struct NDIS_802_11_WEP, KeyMaterial);
if (wep_key_len == 13) {
padapter->securitypriv.PrivacyAlgrthm = _WEP104_;
padapter->securitypriv.XGrpPrivacy = _WEP104_;
@ -1555,7 +1555,7 @@ static int r8711_wx_set_enc(struct net_device *dev,
if (erq->length > 0) {
wep.KeyLength = erq->length <= 5 ? 5 : 13;
wep.Length = wep.KeyLength +
FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial);
offsetof(struct NDIS_802_11_WEP, KeyMaterial);
} else {
wep.KeyLength = 0;
if (keyindex_provided == 1) { /* set key_id only, no given