staging: rtl8723bs: Replace network magic numbers with EtherType macros
PATCH 1/1 staging: rtl8723bs: Replace network magic numbers with EtherType macros
Replace hardcoded magic numbers for network protocols (e.g., 0x0806 for ARP, 0x888e for EAPOL) with their standard EtherType macro equivalents (ETH_P_ARP, ETH_P_PAE) defined in <linux/if_ether.h>.
This change improves code readability and aligns the driver with standard Linux networking definitions.
--- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +5 -3
@@ -4,6 +4,8 @@* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ +#include "linux/delay.h" +#include "linux/if_ether.h" #include <drv_types.h> static u8 P802_1H_OUI [P80211_OUI_LEN ] = {0x00 ,0x00 ,0xf8 };
@@ -128,7 +130,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)/* Tx buf allocation may fail sometimes, so sleep and retry. */ res =rtw_os_xmit_resource_alloc (padapter, pxmitbuf, (MAX_XMITBUF_SZ +XMITBUF_ALIGN_SZ ), true);if (res == _FAIL) { -msleep (10 ); +usleep_range (10000 ,11000 ); res =rtw_os_xmit_resource_alloc (padapter, pxmitbuf, (MAX_XMITBUF_SZ +XMITBUF_ALIGN_SZ ), true);if (res == _FAIL) goto exit;
@@ -2026,8 +2028,8 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe)if (registry->hiq_filter ==RTW_HIQ_FILTER_ALLOW_SPECIAL ) {struct pkt_attrib *attrib = &xmitframe->attrib; -if (attrib->ether_type ==0x0806 || - attrib->ether_type ==0x888e || +if (attrib->ether_type ==ETH_P_ARP || + attrib->ether_type ==ETH_P_PAE || attrib->dhcp_pkt ) allow = true;
Signature · 1 line
2.53.0
Quoted 9 lines · Marcos Andrade
Replace hardcoded magic numbers for network protocols (e.g.,
0x0806for ARP,0x888efor EAPOL) with their standard EtherType macro equivalents (ETH_P_ARP,ETH_P_PAE) defined in <linux/if_ether.h>.This change improves code readability and aligns the driver with standard Linux networking definitions.
Signed-off-by Marcos Andrade <[email protected]>---
...
drivers/staging/rtl8723bs/core/rtw_xmit.c line 8
Quoted 2 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +2
-0+#include "linux/delay.h" +#include "linux/if_ether.h"
You always include linux api headers with <> not "". Also, header files should be included in alphabetical order:
Quoted 1 line
#include <
drv_types.h>
#include <linux/if_ether.h>
You won't include <linux/delay.h> in your v2 for reasons below.
drivers/staging/rtl8723bs/core/rtw_xmit.c s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) · line 133
Quoted 8 lines
static u8 P802_1H_OUI[P80211_OUI_LEN] = {
0x00,0x00,0xf8};drivers/staging/rtl8723bs/core/rtw_xmit.c +1
-1@@ -128,7 +130,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)/* Tx buf allocation may fail sometimes, so sleep and retry. */ res =rtw_os_xmit_resource_alloc (padapter, pxmitbuf, (MAX_XMITBUF_SZ +XMITBUF_ALIGN_SZ ), true);if (res == _FAIL) { -msleep (10 ); +usleep_range (10000 ,11000 );
You didn't mention this in your changelog and is an unrelated change. Please make this its own separate patch. Also, this should be changed from msleep(10) to fsleep(10 * USEC_PER_MSEC) as this is the new standard API.
Thanks,
ET