From 7f8451a86ee91ac32f6d22d90948e8ea3aec39f3 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:41 -0500 Subject: [PATCH 01/24] Remove wrapper rtw_mdelay_os() This wrapper just calls mdelay(). Remove it. Link: https://lore.kernel.org/r/20210805192644.15978-3-Larry.Finger@lwfinger.net --- core/efuse/rtw_efuse.c | 6 ++--- core/rtw_mp.c | 6 ++--- core/rtw_pwrctrl.c | 6 ++--- hal/btc/halbtc8192e2ant.c | 4 +-- hal/btc/mp_precomp.h | 2 -- hal/hal_com.c | 2 +- hal/hal_com_phycfg.c | 18 ++++++------- hal/hal_mp.c | 2 +- hal/phydm/halrf/halphyrf_ap.c | 4 +-- hal/phydm/phydm_interface.c | 12 ++++----- hal/phydm/txbf/haltxbf8822b.c | 2 +- hal/rtl8192e/rtl8192e_cmd.c | 2 +- hal/rtl8192e/rtl8192e_hal_init.c | 6 ++--- hal/rtl8192e/rtl8192e_phycfg.c | 4 +-- include/osdep_service.h | 3 --- os_dep/linux/rtw_android.c | 2 +- os_dep/osdep_service.c | 45 -------------------------------- platform/platform_sprd_sdio.c | 8 +++--- 18 files changed, 42 insertions(+), 92 deletions(-) diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index 570414b..a703589 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -2097,7 +2097,7 @@ efuse_OneByteRead( rtw_write8(pAdapter, EFUSE_CTRL + 3, (readbyte & 0x7f)); while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 1000)) { - rtw_mdelay_os(1); + mdelay(1); tmpidx++; } if (tmpidx < 100) { @@ -2158,10 +2158,10 @@ efuse_OneByteWrite( } else rtw_write32(pAdapter, EFUSE_CTRL, efuseValue); - rtw_mdelay_os(1); + mdelay(1); while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) { - rtw_mdelay_os(1); + mdelay(1); tmpidx++; } diff --git a/core/rtw_mp.c b/core/rtw_mp.c index f7d221a..9175f6a 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -2388,11 +2388,11 @@ static u32 rtw_GetPSDData(PADAPTER pAdapter, u32 point) psd_val |= point; rtw_write32(pAdapter, psd_reg, psd_val); - rtw_mdelay_os(1); + mdelay(1); psd_val |= 0x00400000; rtw_write32(pAdapter, psd_reg, psd_val); - rtw_mdelay_os(1); + mdelay(1); psd_val = rtw_read32(pAdapter, psd_regL); #if defined(CONFIG_RTL8821C) @@ -2457,7 +2457,7 @@ u32 mp_query_psd(PADAPTER pAdapter, u8 *data) #ifdef CONFIG_LONG_DELAY_ISSUE msleep(100); #else - rtw_mdelay_os(100); + mdelay(100); #endif if (psd_analysis) diff --git a/core/rtw_pwrctrl.c b/core/rtw_pwrctrl.c index e3445fd..7aeaf3a 100644 --- a/core/rtw_pwrctrl.c +++ b/core/rtw_pwrctrl.c @@ -781,7 +781,7 @@ void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable) cnt++; RTW_INFO("%s polling REG_HMETFR=0x%x, cnt=%d\n", __func__, val8, cnt); - rtw_mdelay_os(10); + mdelay(10); } while (cnt < 100 && (val8 != 0)); #ifdef CONFIG_LPS_LCLK @@ -806,7 +806,7 @@ void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable) __func__, rtw_read8(padapter, 0x08), rtw_read8(padapter, 0x03)); - rtw_mdelay_os(10); + mdelay(10); } while (cnt < 20 && (val8 != 0xEA)); } } @@ -832,7 +832,7 @@ void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable) start_time = rtw_get_current_time(); do { - rtw_mdelay_os(1); + mdelay(1); rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_now); if ((cpwm_orig ^ cpwm_now) & 0x80) diff --git a/hal/btc/halbtc8192e2ant.c b/hal/btc/halbtc8192e2ant.c index 8bc80d0..1465f2f 100644 --- a/hal/btc/halbtc8192e2ant.c +++ b/hal/btc/halbtc8192e2ant.c @@ -942,7 +942,7 @@ void halbtc8192e2ant_dac_swing(IN struct btc_coexist *btcoexist, coex_dm->cur_dac_swing_lvl)) return; } - delay_ms(30); + mdelay(30); halbtc8192e2ant_set_sw_full_time_dac_swing(btcoexist, dac_swing_on, dac_swing_lvl); @@ -1562,7 +1562,7 @@ void halbtc8192e2ant_ps_tdma(IN struct btc_coexist *btcoexist, break; case 1: /* ANT2BT, 0x778=3 */ halbtc8192e2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - delay_ms(5); + mdelay(5); halbtc8192e2ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false, false); break; } diff --git a/hal/btc/mp_precomp.h b/hal/btc/mp_precomp.h index 35f5a9c..798d7df 100644 --- a/hal/btc/mp_precomp.h +++ b/hal/btc/mp_precomp.h @@ -29,8 +29,6 @@ #define DCMD_Printf DBG_BT_INFO -#define delay_ms(ms) rtw_mdelay_os(ms) - #ifdef bEnable #undef bEnable #endif diff --git a/hal/hal_com.c b/hal/hal_com.c index 62454a1..cb6ddad 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -8770,7 +8770,7 @@ static void rtw_hal_gate_bb(_adapter *adapter, bool stop) } else { RTW_WARN("%s: MGQ_CPU is busy(%d)!\n", __func__, i); - rtw_mdelay_os(10); + mdelay(10); } } diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c index d186310..7e89e64 100644 --- a/hal/hal_com_phycfg.c +++ b/hal/hal_com_phycfg.c @@ -4209,12 +4209,12 @@ phy_ConfigBBWithParaFile( #ifdef CONFIG_LONG_DELAY_ISSUE msleep(50); #else - rtw_mdelay_os(50); + mdelay(50); #endif } else if (u4bRegOffset == 0xfd) - rtw_mdelay_os(5); + mdelay(5); else if (u4bRegOffset == 0xfc) - rtw_mdelay_os(1); + mdelay(1); else if (u4bRegOffset == 0xfb) rtw_udelay_os(50); else if (u4bRegOffset == 0xfa) @@ -4557,12 +4557,12 @@ phy_ConfigBBWithMpParaFile( #ifdef CONFIG_LONG_DELAY_ISSUE msleep(50); #else - rtw_mdelay_os(50); + mdelay(50); #endif } else if (u4bRegOffset == 0xfd) - rtw_mdelay_os(5); + mdelay(5); else if (u4bRegOffset == 0xfc) - rtw_mdelay_os(1); + mdelay(1); else if (u4bRegOffset == 0xfb) rtw_udelay_os(50); else if (u4bRegOffset == 0xfa) @@ -4671,14 +4671,14 @@ PHY_ConfigRFWithParaFile( #ifdef CONFIG_LONG_DELAY_ISSUE msleep(50); #else - rtw_mdelay_os(50); + mdelay(50); #endif } else if (u4bRegOffset == 0xfd) { - /* delay_ms(5); */ + /* mdelay(5); */ for (i = 0; i < 100; i++) rtw_udelay_os(MAX_STALL_TIME); } else if (u4bRegOffset == 0xfc) { - /* delay_ms(1); */ + /* mdelay(1); */ for (i = 0; i < 20; i++) rtw_udelay_os(MAX_STALL_TIME); } else if (u4bRegOffset == 0xfb) diff --git a/hal/hal_mp.c b/hal/hal_mp.c index a6811a2..fab9814 100644 --- a/hal/hal_mp.c +++ b/hal/hal_mp.c @@ -2055,7 +2055,7 @@ static VOID mpt_StopOfdmContTx( else phy_set_bb_reg(pAdapter, rOFDM1_LSTF, BIT30 | BIT29 | BIT28, OFDM_ALL_OFF); - rtw_mdelay_os(10); + mdelay(10); if (!IS_HARDWARE_TYPE_JAGUAR(pAdapter) && !IS_HARDWARE_TYPE_JAGUAR2(pAdapter)) { phy_set_bb_reg(pAdapter, 0xa14, 0x300, 0x0); /* 0xa15[1:0] = 0*/ diff --git a/hal/phydm/halrf/halphyrf_ap.c b/hal/phydm/halrf/halphyrf_ap.c index c4967e2..4df219e 100644 --- a/hal/phydm/halrf/halphyrf_ap.c +++ b/hal/phydm/halrf/halphyrf_ap.c @@ -300,7 +300,7 @@ odm_txpowertracking_callback_thermal_meter_92e( reg0x18 = phy_query_rf_reg(priv, RF_PATH_A, 0x18, MASK20BITS, 1); phy_set_rf_reg(priv, RF_PATH_A, 0xB4, BIT(14), 1); phy_set_rf_reg(priv, RF_PATH_A, 0x18, BIT(15), 1); - delay_ms(1); + mdelay(1); phy_set_rf_reg(priv, RF_PATH_A, 0xB4, BIT(14), 0); phy_set_rf_reg(priv, RF_PATH_A, 0x18, MASK20BITS, reg0x18); RTL_W8(0x522, 0x0); @@ -1003,7 +1003,7 @@ odm_txpowertracking_callback_thermal_meter_jaguar_series( reg0x18 = phy_query_rf_reg(priv, RF_PATH_A, 0x18, MASK20BITS, 1); phy_set_rf_reg(priv, RF_PATH_A, 0xB4, BIT(14), 1); phy_set_rf_reg(priv, RF_PATH_A, 0x18, BIT(15), 1); - delay_ms(200); /* frequency deviation */ + mdelay(200); /* frequency deviation */ phy_set_rf_reg(priv, RF_PATH_A, 0xB4, BIT(14), 0); phy_set_rf_reg(priv, RF_PATH_A, 0x18, MASK20BITS, reg0x18); #ifdef CONFIG_RTL_8812_SUPPORT diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c index c5f9799..bf5fb55 100644 --- a/hal/phydm/phydm_interface.c +++ b/hal/phydm/phydm_interface.c @@ -592,17 +592,17 @@ odm_is_work_item_scheduled( void ODM_delay_ms(u32 ms) { #if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) - delay_ms(ms); + mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211) mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) - rtw_mdelay_os(ms); + mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN) - delay_ms(ms); + mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT) - rtw_mdelay_os(ms); + mdelay(ms); #endif } @@ -626,7 +626,7 @@ void ODM_delay_us(u32 us) void ODM_sleep_ms(u32 ms) { #if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) - delay_ms(ms); + mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211) msleep(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) @@ -634,7 +634,7 @@ void ODM_sleep_ms(u32 ms) #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) msleep(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN) - delay_ms(ms); + mdelay(ms); #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT) msleep(ms); #endif diff --git a/hal/phydm/txbf/haltxbf8822b.c b/hal/phydm/txbf/haltxbf8822b.c index f25912a..a40316c 100644 --- a/hal/phydm/txbf/haltxbf8822b.c +++ b/hal/phydm/txbf/haltxbf8822b.c @@ -600,7 +600,7 @@ void hal_txbf_8822b_enter( hal_txbf_8822b_rf_mode(dm, beamforming_info, bfee_idx); #if (SUPPORT_MU_BF == 1) /*Special for plugfest*/ - delay_ms(50); /* wait for 4-way handshake ending*/ + mdelay(50); /* wait for 4-way handshake ending*/ send_sw_vht_gid_mgnt_frame(dm, p_beamformee_entry->mac_addr, bfee_idx); #endif diff --git a/hal/rtl8192e/rtl8192e_cmd.c b/hal/rtl8192e/rtl8192e_cmd.c index 6dbeaac..4c20be3 100644 --- a/hal/rtl8192e/rtl8192e_cmd.c +++ b/hal/rtl8192e/rtl8192e_cmd.c @@ -354,7 +354,7 @@ void rtl8192e_download_rsvd_page(PADAPTER padapter, u8 mstatus) DLBcnCount++; do { yield(); - /* rtw_mdelay_os(10); */ + /* mdelay(10); */ /* check rsvd page download OK. */ rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); poll++; diff --git a/hal/rtl8192e/rtl8192e_hal_init.c b/hal/rtl8192e/rtl8192e_hal_init.c index c31564e..eb7d39f 100644 --- a/hal/rtl8192e/rtl8192e_hal_init.c +++ b/hal/rtl8192e/rtl8192e_hal_init.c @@ -3867,8 +3867,8 @@ u8 SetHwReg8192E(PADAPTER Adapter, u8 variable, u8 *val) ulCommand = CAM_CONTENT_COUNT * ucIndex + i; ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE; /* write content 0 is equall to mark invalid */ - rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ - rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ + rtw_write32(Adapter, WCAMI, ulContent); /* mdelay(40); */ + rtw_write32(Adapter, RWCAM, ulCommand); /* mdelay(40); */ } } break; @@ -3994,7 +3994,7 @@ u8 SetHwReg8192E(PADAPTER Adapter, u8 variable, u8 *val) /* RQPN Load 0 */ rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); rtw_write32(Adapter, REG_RQPN, 0x80000000); - rtw_mdelay_os(10); + mdelay(10); } } break; diff --git a/hal/rtl8192e/rtl8192e_phycfg.c b/hal/rtl8192e/rtl8192e_phycfg.c index 6842de4..8dc9d3c 100644 --- a/hal/rtl8192e/rtl8192e_phycfg.c +++ b/hal/rtl8192e/rtl8192e_phycfg.c @@ -931,7 +931,7 @@ phy_SpurCalibration_8192E( phy_set_bb_reg(Adapter, rFPGA0_PSDFunction, bMaskDWord, 0xfccd); phy_set_bb_reg(Adapter, rFPGA0_PSDFunction, bMaskDWord, 0x40fccd); /* msleep(30); */ - rtw_mdelay_os(30); + mdelay(30); PSDReport = phy_query_bb_reg(Adapter, rFPGA0_PSDReport, bMaskDWord); /* RTW_INFO(" Path A== PSDReport = 0x%x (%d)\n",PSDReport,PSDReport); */ if (PSDReport < 0x16) @@ -946,7 +946,7 @@ phy_SpurCalibration_8192E( phy_set_bb_reg(Adapter, rFPGA0_PSDFunction, bMaskDWord, 0xfccd); phy_set_bb_reg(Adapter, rFPGA0_PSDFunction, bMaskDWord, 0x40fccd); /* msleep(30); */ - rtw_mdelay_os(30); + mdelay(30); PSDReport = phy_query_bb_reg(Adapter, rFPGA0_PSDReport, bMaskDWord); /* RTW_INFO(" Path B== PSDReport = 0x%x (%d)\n",PSDReport,PSDReport); */ if (PSDReport < 0x16) diff --git a/include/osdep_service.h b/include/osdep_service.h index 093e405..1f2572a 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -369,12 +369,9 @@ extern void rtw_usleep_os(int us); extern u32 rtw_atoi(u8 *s); #ifdef DBG_DELAY_OS -#define rtw_mdelay_os(ms) _rtw_mdelay_os((ms), __FUNCTION__, __LINE__) #define rtw_udelay_os(ms) _rtw_udelay_os((ms), __FUNCTION__, __LINE__) -extern void _rtw_mdelay_os(int ms, const char *func, const int line); extern void _rtw_udelay_os(int us, const char *func, const int line); #else -extern void rtw_mdelay_os(int ms); extern void rtw_udelay_os(int us); #endif diff --git a/os_dep/linux/rtw_android.c b/os_dep/linux/rtw_android.c index d0780df..93c4f77 100644 --- a/os_dep/linux/rtw_android.c +++ b/os_dep/linux/rtw_android.c @@ -1186,7 +1186,7 @@ static void shutdown_card(void) break; } - rtw_mdelay_os(10); + mdelay(10); } while (1); /* unlock register I/O */ diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 3d35bf3..1aad193 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1606,32 +1606,7 @@ void rtw_usleep_os(int us) } - #ifdef DBG_DELAY_OS -void _rtw_mdelay_os(int ms, const char *func, const int line) -{ -#if 0 - if (ms > 10) - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); - msleep(ms); - return; -#endif - - - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); - -#if defined(PLATFORM_LINUX) - - mdelay((unsigned long)ms); - -#elif defined(PLATFORM_WINDOWS) - - NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */ - -#endif - - -} void _rtw_udelay_os(int us, const char *func, const int line) { @@ -1658,27 +1633,7 @@ void _rtw_udelay_os(int us, const char *func, const int line) #endif } -#else -void rtw_mdelay_os(int ms) -{ -#ifdef PLATFORM_LINUX - - mdelay((unsigned long)ms); - -#endif -#ifdef PLATFORM_FREEBSD - DELAY(ms * 1000); - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */ - -#endif - - -} void rtw_udelay_os(int us) { diff --git a/platform/platform_sprd_sdio.c b/platform/platform_sprd_sdio.c index 34061d0..035d00c 100644 --- a/platform/platform_sprd_sdio.c +++ b/platform/platform_sprd_sdio.c @@ -41,15 +41,15 @@ int platform_wifi_power_on(void) /* Pull up BT reset pin. */ rtw_wifi_gpio_wlan_ctrl(WLAN_BT_PWDN_ON); #endif - rtw_mdelay_os(5); + mdelay(5); sdhci_bus_scan(); #ifdef CONFIG_RTL8723B /* YJ,test,130305 */ - rtw_mdelay_os(1000); + mdelay(1000); #endif #ifdef ANDROID_2X - rtw_mdelay_os(200); + mdelay(200); #else /* !ANDROID_2X */ if (1) { int i = 0; @@ -70,7 +70,7 @@ void platform_wifi_power_off(void) { /* Pull down pwd pin, make wifi enter power down mode. */ rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_OFF); - rtw_mdelay_os(5); + mdelay(5); rtw_wifi_gpio_deinit(); #ifdef CONFIG_RTL8188E From a5adfa895bd492f798eb636c7f3f2ef7fdba8a9f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:42 -0500 Subject: [PATCH 02/24] Remove wrapper rtw_udelay_os() This wrapper is a simple call to udelay(). Remove it. Link: https://lore.kernel.org/r/20210805192644.15978-4-Larry.Finger@lwfinger.net --- core/efuse/rtw_efuse.c | 2 +- core/rtw_eeprom.c | 12 ++++----- core/rtw_xmit.c | 2 +- hal/HalPwrSeqCmd.c | 6 ++--- hal/hal_com.c | 4 +-- hal/hal_com_phycfg.c | 28 +++++++++---------- hal/hal_halmac.c | 2 +- hal/hal_intf.c | 2 +- hal/phydm/phydm_interface.c | 4 +-- hal/rtl8192e/rtl8192e_phycfg.c | 4 +-- hal/rtl8192e/rtl8192e_rf6052.c | 8 +++--- include/autoconf.h | 1 - include/osdep_service.h | 7 ----- os_dep/osdep_service.c | 49 ---------------------------------- 14 files changed, 37 insertions(+), 94 deletions(-) diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index a703589..e99dd7c 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -1985,7 +1985,7 @@ ReadEFuseByte( /* This fix the problem that Efuse read error in high temperature condition. */ /* Designer says that there shall be some delay after ready bit is set, or the */ /* result will always stay on last data we read. */ - rtw_udelay_os(50); + udelay(50); value32 = rtw_read32(Adapter, EFUSE_CTRL); *pbuf = (u8)(value32 & 0xff); diff --git a/core/rtw_eeprom.c b/core/rtw_eeprom.c index d48996e..1537755 100644 --- a/core/rtw_eeprom.c +++ b/core/rtw_eeprom.c @@ -22,7 +22,7 @@ void up_clk(_adapter *padapter, u16 *x) { *x = *x | _EESK; rtw_write8(padapter, EE_9346CR, (u8)*x); - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); } @@ -31,7 +31,7 @@ void down_clk(_adapter *padapter, u16 *x) { *x = *x & ~_EESK; rtw_write8(padapter, EE_9346CR, (u8)*x); - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); } void shift_out_bits(_adapter *padapter, u16 data, u16 count) @@ -54,7 +54,7 @@ void shift_out_bits(_adapter *padapter, u16 data, u16 count) goto out; } rtw_write8(padapter, EE_9346CR, (u8)x); - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); up_clk(padapter, &x); down_clk(padapter, &x); mask = mask >> 1; @@ -106,10 +106,10 @@ void standby(_adapter *padapter) x &= ~(_EECS | _EESK); rtw_write8(padapter, EE_9346CR, x); - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); x |= _EECS; rtw_write8(padapter, EE_9346CR, x); - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); } u16 wait_eeprom_cmd_done(_adapter *padapter) @@ -123,7 +123,7 @@ u16 wait_eeprom_cmd_done(_adapter *padapter) res = _TRUE; goto exit; } - rtw_udelay_os(CLOCK_RATE); + udelay(CLOCK_RATE); } exit: return res; diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index fb99327..9c9f569 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -4418,7 +4418,7 @@ s32 rtw_monitor_xmit_entry(struct sk_buff *skb, struct net_device *ndev) #endif pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (pmgntframe == NULL) { - rtw_udelay_os(500); + udelay(500); goto fail; } diff --git a/hal/HalPwrSeqCmd.c b/hal/HalPwrSeqCmd.c index 389785c..fbac1fe 100644 --- a/hal/HalPwrSeqCmd.c +++ b/hal/HalPwrSeqCmd.c @@ -132,7 +132,7 @@ u8 HalPwrSeqCmdParsing( if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd))) bPollingBit = _TRUE; else - rtw_udelay_os(10); + udelay(10); if (pollingCount++ > maxPollingCnt) { RTW_ERR("HalPwrSeqCmdParsing: Fail to polling Offset[%#x]=%02x\n", offset, value); @@ -163,9 +163,9 @@ u8 HalPwrSeqCmdParsing( case PWR_CMD_DELAY: if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) - rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd)); + udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)); else - rtw_udelay_os(GET_PWR_CFG_OFFSET(PwrCfgCmd) * 1000); + udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd) * 1000); break; case PWR_CMD_END: diff --git a/hal/hal_com.c b/hal/hal_com.c index cb6ddad..d0cb0b3 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -9016,7 +9016,7 @@ bool rtw_read_from_frame_mask(_adapter *adapter, u8 idx) do { tmp = rtw_read8(adapter, REG_RXPKTBUF_CTRL); - rtw_udelay_os(2); + udelay(2); count++; } while (!tmp && count < 100); @@ -9127,7 +9127,7 @@ bool rtw_write_to_frame_mask(_adapter *adapter, u8 idx, count = 0; do { tmp = rtw_read8(adapter, REG_RXPKTBUF_CTRL); - rtw_udelay_os(2); + udelay(2); count++; } while (tmp && count < 100); diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c index 7e89e64..6424101 100644 --- a/hal/hal_com_phycfg.c +++ b/hal/hal_com_phycfg.c @@ -4216,11 +4216,11 @@ phy_ConfigBBWithParaFile( else if (u4bRegOffset == 0xfc) mdelay(1); else if (u4bRegOffset == 0xfb) - rtw_udelay_os(50); + udelay(50); else if (u4bRegOffset == 0xfa) - rtw_udelay_os(5); + udelay(5); else if (u4bRegOffset == 0xf9) - rtw_udelay_os(1); + udelay(1); /* Get 2nd hex value as register value. */ szLine += u4bMove; @@ -4232,7 +4232,7 @@ phy_ConfigBBWithParaFile( pHalData->odmpriv.rf_calibrate_info.rega24 = u4bRegValue; /* Add 1us delay between BB/RF register setting. */ - rtw_udelay_os(1); + udelay(1); } } } @@ -4564,11 +4564,11 @@ phy_ConfigBBWithMpParaFile( else if (u4bRegOffset == 0xfc) mdelay(1); else if (u4bRegOffset == 0xfb) - rtw_udelay_os(50); + udelay(50); else if (u4bRegOffset == 0xfa) - rtw_udelay_os(5); + udelay(5); else if (u4bRegOffset == 0xf9) - rtw_udelay_os(1); + udelay(1); /* Get 2nd hex value as register value. */ szLine += u4bMove; @@ -4577,7 +4577,7 @@ phy_ConfigBBWithMpParaFile( phy_set_bb_reg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue); /* Add 1us delay between BB/RF register setting. */ - rtw_udelay_os(1); + udelay(1); } } } @@ -4676,17 +4676,17 @@ PHY_ConfigRFWithParaFile( } else if (u4bRegOffset == 0xfd) { /* mdelay(5); */ for (i = 0; i < 100; i++) - rtw_udelay_os(MAX_STALL_TIME); + udelay(MAX_STALL_TIME); } else if (u4bRegOffset == 0xfc) { /* mdelay(1); */ for (i = 0; i < 20; i++) - rtw_udelay_os(MAX_STALL_TIME); + udelay(MAX_STALL_TIME); } else if (u4bRegOffset == 0xfb) - rtw_udelay_os(50); + udelay(50); else if (u4bRegOffset == 0xfa) - rtw_udelay_os(5); + udelay(5); else if (u4bRegOffset == 0xf9) - rtw_udelay_os(1); + udelay(1); else if (u4bRegOffset == 0xffff) break; @@ -4703,7 +4703,7 @@ PHY_ConfigRFWithParaFile( /* 0x2b 0x00808 frequency divider. */ /* 0x2b 0x53333 */ /* 0x2c 0x0000c */ - rtw_udelay_os(1); + udelay(1); } } } diff --git a/hal/hal_halmac.c b/hal/hal_halmac.c index 320219b..907e487 100644 --- a/hal/hal_halmac.c +++ b/hal/hal_halmac.c @@ -410,7 +410,7 @@ static void _halmac_udelay(void *p, u32 us) { /* Most hardware polling wait time < 50us) */ if (us <= 50) - rtw_udelay_os(us); + udelay(us); else if (us <= 1000) rtw_usleep_os(us); else diff --git a/hal/hal_intf.c b/hal/hal_intf.c index c3aab45..bdfeb4e 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -739,7 +739,7 @@ void rtw_hal_write_rfreg(_adapter *padapter, enum rf_path eRFPath, u32 RegAddr, #ifdef CONFIG_PCI_HCI if (!IS_HARDWARE_TYPE_JAGUAR_AND_JAGUAR2(padapter)) /*For N-Series IC, suggest by Jenyu*/ - rtw_udelay_os(2); + udelay(2); #endif } } diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c index bf5fb55..1136fd4 100644 --- a/hal/phydm/phydm_interface.c +++ b/hal/phydm/phydm_interface.c @@ -615,11 +615,11 @@ void ODM_delay_us(u32 us) #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) udelay(us); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) - rtw_udelay_os(us); + udelay(us); #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN) PlatformStallExecution(us); #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT) - rtw_udelay_os(us); + udelay(us); #endif } diff --git a/hal/rtl8192e/rtl8192e_phycfg.c b/hal/rtl8192e/rtl8192e_phycfg.c index 8dc9d3c..55707df 100644 --- a/hal/rtl8192e/rtl8192e_phycfg.c +++ b/hal/rtl8192e/rtl8192e_phycfg.c @@ -140,11 +140,11 @@ phy_RFSerialRead( phy_set_bb_reg(Adapter, rFPGA0_XA_HSSIParameter2 | MaskforPhySet, bMaskDWord, tmplong2 & (~bLSSIReadEdge)); phy_set_bb_reg(Adapter, rFPGA0_XA_HSSIParameter2 | MaskforPhySet, bMaskDWord, tmplong2 | bLSSIReadEdge); - rtw_udelay_os(10);/* PlatformStallExecution(10); */ + udelay(10);/* PlatformStallExecution(10); */ /* for(i=0;i<2;i++) */ /* PlatformStallExecution(MAX_STALL_TIME); */ - rtw_udelay_os(10);/* PlatformStallExecution(10); */ + udelay(10);/* PlatformStallExecution(10); */ if (eRFPath == RF_PATH_A) RfPiEnable = (u1Byte)phy_query_bb_reg(Adapter, rFPGA0_XA_HSSIParameter1 | MaskforPhySet, BIT8); diff --git a/hal/rtl8192e/rtl8192e_rf6052.c b/hal/rtl8192e/rtl8192e_rf6052.c index 4bc63e2..a0d74f2 100644 --- a/hal/rtl8192e/rtl8192e_rf6052.c +++ b/hal/rtl8192e/rtl8192e_rf6052.c @@ -94,18 +94,18 @@ phy_RF6052_Config_ParaFile_8192E( /*----Set RF_ENV enable----*/ phy_set_bb_reg(Adapter, pPhyReg->rfintfe | MaskforPhySet, bRFSI_RFENV << 16, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ phy_set_bb_reg(Adapter, pPhyReg->rfintfo | MaskforPhySet, bRFSI_RFENV, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /* Set bit number of Address and Data for RF register */ phy_set_bb_reg(Adapter, pPhyReg->rfHSSIPara2 | MaskforPhySet, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ phy_set_bb_reg(Adapter, pPhyReg->rfHSSIPara2 | MaskforPhySet, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { diff --git a/include/autoconf.h b/include/autoconf.h index b96b062..bd75643 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -286,7 +286,6 @@ /* #define DBG_CMD_QUEUE */ /* #define DBG_IO */ -/* #define DBG_DELAY_OS */ /* #define DBG_MEM_ALLOC */ /* #define DBG_IOCTL */ diff --git a/include/osdep_service.h b/include/osdep_service.h index 1f2572a..ab24553 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -368,13 +368,6 @@ extern void rtw_usleep_os(int us); extern u32 rtw_atoi(u8 *s); -#ifdef DBG_DELAY_OS -#define rtw_udelay_os(ms) _rtw_udelay_os((ms), __FUNCTION__, __LINE__) -extern void _rtw_udelay_os(int us, const char *func, const int line); -#else -extern void rtw_udelay_os(int us); -#endif - extern void rtw_init_timer(_timer *ptimer, void *padapter, void *pfunc, void *ctx); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 1aad193..13a62c8 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1606,55 +1606,6 @@ void rtw_usleep_os(int us) } -#ifdef DBG_DELAY_OS -void _rtw_udelay_os(int us, const char *func, const int line) -{ - -#if 0 - if (us > 1000) { - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); - rtw_usleep_os(us); - return; - } -#endif - - - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); - - -#if defined(PLATFORM_LINUX) - - udelay((unsigned long)us); - -#elif defined(PLATFORM_WINDOWS) - - NdisStallExecution(us); /* (us) */ - -#endif - -} - -void rtw_udelay_os(int us) -{ - -#ifdef PLATFORM_LINUX - - udelay((unsigned long)us); - -#endif -#ifdef PLATFORM_FREEBSD - /* Delay for delay microseconds */ - DELAY(us); - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisStallExecution(us); /* (us) */ - -#endif - -} -#endif bool rtw_macaddr_is_larger(const u8 *a, const u8 *b) { From 9ad10523e382e8268527fe4f8ad4de027ea137a6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:44 -0500 Subject: [PATCH 03/24] Remove wrapper rtw_sleep_schedulable() This wrapper is never used. Link: https://lore.kernel.org/r/20210805192644.15978-6-Larry.Finger@lwfinger.net --- include/osdep_service.h | 2 -- os_dep/osdep_service.c | 31 ------------------------------- 2 files changed, 33 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index ab24553..e0afc2d 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -362,8 +362,6 @@ extern bool _rtw_time_after(systime a, systime b); #define rtw_time_before(a,b) _rtw_time_after(b,a) #endif -extern void rtw_sleep_schedulable(int ms); - extern void rtw_usleep_os(int us); extern u32 rtw_atoi(u8 *s); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 13a62c8..3621b6e 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -1545,37 +1545,6 @@ inline bool _rtw_time_after(systime a, systime b) #endif } -void rtw_sleep_schedulable(int ms) -{ - -#ifdef PLATFORM_LINUX - - u32 delta; - - delta = (ms * HZ) / 1000; /* (ms) */ - if (delta == 0) { - delta = 1;/* 1 ms */ - } - set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(delta) != 0) - return ; - return; - -#endif -#ifdef PLATFORM_FREEBSD - DELAY(ms * 1000); - return ; -#endif - -#ifdef PLATFORM_WINDOWS - - NdisMSleep(ms * 1000); /* (us)*1000=(ms) */ - -#endif - -} - - void rtw_usleep_os(int us) { #ifdef PLATFORM_LINUX From 2965c273c94e3a8627cf35d4169786f4aa2b778d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:36 +0200 Subject: [PATCH 04/24] remove the RT_TRACE macro We've deleted all RT_TRACE calls. The macro itself can now be removed as well. Link: https://lore.kernel.org/r/20210807153636.11712-13-martin@kaiser.cx --- hal/hal_btcoex.c | 2 -- hal/phydm/halrf/halrf_debug.h | 2 -- hal/phydm/halrf/halrf_powertracking_ce.c | 2 -- hal/phydm/halrf/halrf_powertracking_iot.c | 1 - hal/phydm/halrf/halrf_powertracking_win.c | 9 +-------- hal/phydm/phydm_debug.h | 14 +------------- hal/phydm/phydm_dfs.c | 1 - hal/phydm/phydm_interface.c | 1 - hal/phydm/txbf/haltxbf8822b.c | 1 - 9 files changed, 2 insertions(+), 31 deletions(-) diff --git a/hal/hal_btcoex.c b/hal/hal_btcoex.c index 3001755..9b974e7 100644 --- a/hal/hal_btcoex.c +++ b/hal/hal_btcoex.c @@ -2388,8 +2388,6 @@ u8 halbtcoutsrc_GetAntDetValFromBt(void *pBtcContext) status = NDBG_GetAntDetValFromBt(Adapter, opcodeVer, &AntDetVal); - RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$ halbtcoutsrc_GetAntDetValFromBt(): status = %d, feature = %x\n", status, AntDetVal)); - return AntDetVal; #else return 0; diff --git a/hal/phydm/halrf/halrf_debug.h b/hal/phydm/halrf/halrf_debug.h index ff1ff96..858a273 100644 --- a/hal/phydm/halrf/halrf_debug.h +++ b/hal/phydm/halrf/halrf_debug.h @@ -85,8 +85,6 @@ static __inline void RF_DBG(PDM_ODM_T dm, int comp, char *fmt, ...) do { \ struct dm_struct *__dm = dm; \ if ((comp) & __dm->rf_table.rf_dbg_comp) { \ - RT_TRACE(((struct rtl_priv *)__dm->adapter), \ - COMP_PHYDM, DBG_DMESG, "[RF] " fmt, ##args); \ } \ } while (0) #endif diff --git a/hal/phydm/halrf/halrf_powertracking_ce.c b/hal/phydm/halrf/halrf_powertracking_ce.c index 55ec7bf..926bda9 100644 --- a/hal/phydm/halrf/halrf_powertracking_ce.c +++ b/hal/phydm/halrf/halrf_powertracking_ce.c @@ -848,8 +848,6 @@ void odm_txpowertracking_check_mp(void *dm_void) void *adapter = dm->adapter; if (odm_check_power_status(adapter) == false) { - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, - ("check_pow_status, return false\n")); return; } diff --git a/hal/phydm/halrf/halrf_powertracking_iot.c b/hal/phydm/halrf/halrf_powertracking_iot.c index a0c40dc..1dcc44f 100644 --- a/hal/phydm/halrf/halrf_powertracking_iot.c +++ b/hal/phydm/halrf/halrf_powertracking_iot.c @@ -718,7 +718,6 @@ odm_txpowertracking_check_mp( void *adapter = dm->adapter; if (odm_check_power_status(adapter) == false) { - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("check_pow_status, return false\n")); return; } diff --git a/hal/phydm/halrf/halrf_powertracking_win.c b/hal/phydm/halrf/halrf_powertracking_win.c index bad28f5..5766e95 100644 --- a/hal/phydm/halrf/halrf_powertracking_win.c +++ b/hal/phydm/halrf/halrf_powertracking_win.c @@ -784,7 +784,6 @@ odm_txpowertracking_check_mp( return; if (odm_check_power_status(dm) == false) { - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("check_pow_status return false\n")); return; } @@ -831,11 +830,8 @@ odm_txpowertracking_thermal_meter_check( struct dm_struct *dm = &(pHalData->DM_OutSrc); struct _hal_rf_ *rf = &(dm->rf_table); - if (!(rf->rf_supportability & HAL_RF_TX_PWR_TRACK)) { - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, - ("===>odm_txpowertracking_thermal_meter_check(),mgnt_info->is_txpowertracking is false, return!!\n")); + if (!(rf->rf_supportability & HAL_RF_TX_PWR_TRACK)) return; - } if (!tm_trigger) { if (IS_HARDWARE_TYPE_8188E(adapter) || IS_HARDWARE_TYPE_JAGUAR(adapter) || IS_HARDWARE_TYPE_8192E(adapter) || IS_HARDWARE_TYPE_8192F(adapter) @@ -845,14 +841,11 @@ odm_txpowertracking_thermal_meter_check( else PHY_SetRFReg(adapter, RF_PATH_A, RF_T_METER, RFREGOFFSETMASK, 0x60); - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Trigger Thermal Meter!!\n")); - tm_trigger = 1; return; } else if (IS_HARDWARE_TYPE_8822C(adapter) || IS_HARDWARE_TYPE_8814B(adapter)) return; else { - RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Schedule TxPowerTracking direct call!!\n")); odm_txpowertracking_direct_call(adapter); tm_trigger = 0; } diff --git a/hal/phydm/phydm_debug.h b/hal/phydm/phydm_debug.h index 660f48f..05f06c2 100644 --- a/hal/phydm/phydm_debug.h +++ b/hal/phydm/phydm_debug.h @@ -90,8 +90,6 @@ #define pr_debug printk #define RT_PRINTK(fmt, args...) pr_debug(fmt, ## args) #define RT_DISP(dbgtype, dbgflag, printstr) - #define RT_TRACE(adapter, comp, drv_level, fmt, args...) \ - RTW_INFO(fmt, ## args) #define PHYDM_SNPRINTF snprintf #elif (DM_ODM_SUPPORT_TYPE == ODM_IOT) #define pr_debug(fmt, args...) RTW_PRINT_MSG(fmt, ## args) @@ -250,9 +248,6 @@ static __inline void PHYDM_DBG_F(PDM_ODM_T dm, int comp, char *fmt, ...) do { \ struct dm_struct *__dm = (dm); \ if ((comp) & __dm->debug_components) { \ - RT_TRACE(((struct rtl_priv *)__dm->adapter),\ - COMP_PHYDM, DBG_DMESG, \ - "[PHYDM] " fmt, ##args); \ } \ } while (0) @@ -260,8 +255,6 @@ static __inline void PHYDM_DBG_F(PDM_ODM_T dm, int comp, char *fmt, ...) do { \ struct dm_struct *__dm = (dm); \ if ((comp) & __dm->debug_components) { \ - RT_TRACE(((struct rtl_priv *)__dm->adapter),\ - COMP_PHYDM, DBG_DMESG, fmt, ##args); \ } \ } while (0) @@ -269,9 +262,6 @@ static __inline void PHYDM_DBG_F(PDM_ODM_T dm, int comp, char *fmt, ...) do { \ struct dm_struct *__dm = (dm); \ if ((comp) & __dm->debug_components) { \ - RT_TRACE(((struct rtl_priv *)__dm->adapter),\ - COMP_PHYDM, DBG_DMESG, \ - "[PHYDM] " title_str "%pM\n", addr);\ } \ } while (0) #endif @@ -379,9 +369,7 @@ static __inline void PDM_SNPF(u32 out_len, u32 used, char *buff, int len, #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) #define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) #else -#define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) \ - RT_TRACE(((struct rtl_priv *)dm->adapter), COMP_PHYDM, \ - DBG_DMESG, fmt, ##args) +#define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) #endif #if (PHYDM_DBGPRINT == 1) diff --git a/hal/phydm/phydm_dfs.c b/hal/phydm/phydm_dfs.c index 39c3879..aa7f083 100644 --- a/hal/phydm/phydm_dfs.c +++ b/hal/phydm/phydm_dfs.c @@ -2315,7 +2315,6 @@ void phydm_dfs_ap_reset_radar_detect_counter_and_flag(void *dm_void) odm_set_bb_reg(dm, R_0xa40, BIT(15), 0); odm_set_bb_reg(dm, R_0xa40, BIT(15), 1); - /* RT_TRACE(COMP_DFS, DBG_LOUD, ("[DFS], After reset radar counter, 0xcf8 = 0x%x, 0xcf4 = 0x%x\n", */ /* PHY_QueryBBReg(Adapter, 0xcf8, bMaskDWord), */ /* PHY_QueryBBReg(Adapter, 0xcf4, bMaskDWord))); */ } diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c index 1136fd4..6cdb3f6 100644 --- a/hal/phydm/phydm_interface.c +++ b/hal/phydm/phydm_interface.c @@ -1023,7 +1023,6 @@ u8 phydm_c2H_content_parsing(void *dm_void, u8 c2h_cmd_id, u8 c2h_cmd_len, #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if (dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8821)) { - RT_TRACE(COMP_MP, DBG_LOUD, ("== FW IQK Finish ==\n")); odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK); dm->rf_calibrate_info.is_iqk_in_progress = false; odm_release_spin_lock(dm, RT_IQK_SPINLOCK); diff --git a/hal/phydm/txbf/haltxbf8822b.c b/hal/phydm/txbf/haltxbf8822b.c index a40316c..0c7d985 100644 --- a/hal/phydm/txbf/haltxbf8822b.c +++ b/hal/phydm/txbf/haltxbf8822b.c @@ -185,7 +185,6 @@ hal_txbf_8822b_download_ndpa( platform_efio_write_1byte(adapter, REG_FWHW_TXQ_CTRL_8814A + 2, tmp_reg422 & (~BIT(6))); if (tmp_reg422 & BIT(6)) { - RT_TRACE(COMP_INIT, DBG_LOUD, ("SetBeamformDownloadNDPA_8814A(): There is an adapter is sending beacon.\n")); is_send_beacon = true; } From 03af80bee9fb858e1e8748edd0802b17eff04c39 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 5 Aug 2021 22:50:10 +0200 Subject: [PATCH 05/24] replace custom macros with is_broadcast_ether_addr Replace usage of custom macros with is_broadcast_ether_addr. All buffers are properly aligned. Remove the now unsued macros MacAddr_isBcst and IS_MAC_ADDRESS_BROADCAST. Link: https://lore.kernel.org/r/20210805205010.31192-1-straube.linux@gmail.com --- core/rtw_ioctl_set.c | 7 ------- core/rtw_recv.c | 2 +- core/rtw_sta_mgt.c | 2 +- core/rtw_tdls.c | 2 +- hal/phydm/txbf/haltxbfinterface.c | 2 +- include/wifi.h | 7 ------- 6 files changed, 4 insertions(+), 18 deletions(-) diff --git a/core/rtw_ioctl_set.c b/core/rtw_ioctl_set.c index 9ac1e18..565a734 100644 --- a/core/rtw_ioctl_set.c +++ b/core/rtw_ioctl_set.c @@ -20,13 +20,6 @@ extern void indicate_wx_scan_complete_event(_adapter *padapter); -#define IS_MAC_ADDRESS_BROADCAST(addr) \ - (\ - ((addr[0] == 0xff) && (addr[1] == 0xff) && \ - (addr[2] == 0xff) && (addr[3] == 0xff) && \ - (addr[4] == 0xff) && (addr[5] == 0xff)) ? _TRUE : _FALSE \ - ) - u8 rtw_validate_bssid(u8 *bssid) { u8 ret = _TRUE; diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 1c290b4..71f477b 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -1113,7 +1113,7 @@ void count_rx_stats(_adapter *padapter, union recv_frame *prframe, struct sta_in padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) + if (!is_broadcast_ether_addr(pattrib->dst) && !IS_MCAST(pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; if (sta) diff --git a/core/rtw_sta_mgt.c b/core/rtw_sta_mgt.c index 36972cb..c26d50f 100644 --- a/core/rtw_sta_mgt.c +++ b/core/rtw_sta_mgt.c @@ -713,7 +713,7 @@ u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta) } - if (!((psta->state & WIFI_AP_STATE) || MacAddr_isBcst(psta->cmn.mac_addr)) && is_pre_link_sta == _FALSE) + if (!((psta->state & WIFI_AP_STATE) || is_broadcast_ether_addr(psta->cmn.mac_addr)) && is_pre_link_sta == _FALSE) rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, _FALSE); diff --git a/core/rtw_tdls.c b/core/rtw_tdls.c index 604cd35..32855a7 100644 --- a/core/rtw_tdls.c +++ b/core/rtw_tdls.c @@ -2376,7 +2376,7 @@ int On_TDLS_Dis_Req(_adapter *padapter, union recv_frame *precv_frame) if (psta_ap == NULL) goto exit; dst = pIE->data + 12; - if (MacAddr_isBcst(dst) == _FALSE && (_rtw_memcmp(adapter_mac_addr(padapter), dst, ETH_ALEN) == _FALSE)) + if (MacAddr_isMulticast(dst) == _FALSE && (_rtw_memcmp(adapter_mac_addr(padapter), dst, ETH_ALEN) == _FALSE)) goto exit; break; default: diff --git a/hal/phydm/txbf/haltxbfinterface.c b/hal/phydm/txbf/haltxbfinterface.c index d4aa797..905b117 100644 --- a/hal/phydm/txbf/haltxbfinterface.c +++ b/hal/phydm/txbf/haltxbfinterface.c @@ -54,7 +54,7 @@ void beamforming_gid_paid( /* VHT SU PPDU carrying one or more group addressed MPDUs or */ /* Transmitting a VHT NDP intended for multiple recipients */ - if (MacAddr_isBcst(RA) || MacAddr_isMulticast(RA) || tcb->macId == MAC_ID_STATIC_FOR_BROADCAST_MULTICAST) { + if (is_broadcast_ether_addr(RA) || MacAddr_isMulticast(RA) || tcb->macId == MAC_ID_STATIC_FOR_BROADCAST_MULTICAST) { tcb->G_ID = 63; tcb->P_AID = 0; } else if (ACTING_AS_AP(adapter)) { diff --git a/include/wifi.h b/include/wifi.h index 11bb895..5670c66 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -441,13 +441,6 @@ enum WIFI_REG_DOMAIN { #define GetAddr4Ptr(pbuf) ((unsigned char *)((SIZE_PTR)(pbuf) + 24)) -#define MacAddr_isBcst(addr) \ - (\ - ((addr[0] == 0xff) && (addr[1] == 0xff) && \ - (addr[2] == 0xff) && (addr[3] == 0xff) && \ - (addr[4] == 0xff) && (addr[5] == 0xff)) ? _TRUE : _FALSE \ - ) - __inline static int IS_MCAST(const u8 *da) { if ((*da) & 0x01) From 0faae6386e34cb2cdb7aab93cfe4e979f22f0907 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:34 +0200 Subject: [PATCH 06/24] use IW_HANDLER to declare wext handlers Use the IW_HANDLER macro to declare the handler functions for wext ioctls. We don't have to skip unused ioctl numbers manually. The same modification was applied to the deprecated rtl8188eu driver in commit af249fce390f ("staging: rtl8188eu: use IW_HANDLER to declare wext handlers"). Link: https://lore.kernel.org/r/20210807153636.11712-11-martin@kaiser.cx --- os_dep/linux/ioctl_linux.c | 97 ++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 35e8a64..b52d6db 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -12023,62 +12023,47 @@ free_buf: } static iw_handler rtw_handlers[] = { - NULL, /* SIOCSIWCOMMIT */ - rtw_wx_get_name, /* SIOCGIWNAME */ - dummy, /* SIOCSIWNWID */ - dummy, /* SIOCGIWNWID */ - rtw_wx_set_freq, /* SIOCSIWFREQ */ - rtw_wx_get_freq, /* SIOCGIWFREQ */ - rtw_wx_set_mode, /* SIOCSIWMODE */ - rtw_wx_get_mode, /* SIOCGIWMODE */ - dummy, /* SIOCSIWSENS */ - rtw_wx_get_sens, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - rtw_wx_get_range, /* SIOCGIWRANGE */ - rtw_wx_set_priv, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - dummy, /* SIOCSIWSPY */ - dummy, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - rtw_wx_set_wap, /* SIOCSIWAP */ - rtw_wx_get_wap, /* SIOCGIWAP */ - rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ - dummy, /* SIOCGIWAPLIST -- depricated */ - rtw_wx_set_scan, /* SIOCSIWSCAN */ - rtw_wx_get_scan, /* SIOCGIWSCAN */ - rtw_wx_set_essid, /* SIOCSIWESSID */ - rtw_wx_get_essid, /* SIOCGIWESSID */ - dummy, /* SIOCSIWNICKN */ - rtw_wx_get_nick, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - rtw_wx_set_rate, /* SIOCSIWRATE */ - rtw_wx_get_rate, /* SIOCGIWRATE */ - rtw_wx_set_rts, /* SIOCSIWRTS */ - rtw_wx_get_rts, /* SIOCGIWRTS */ - rtw_wx_set_frag, /* SIOCSIWFRAG */ - rtw_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ - dummy, /* SIOCSIWRETRY */ - rtw_wx_get_retry, /* SIOCGIWRETRY */ - rtw_wx_set_enc, /* SIOCSIWENCODE */ - rtw_wx_get_enc, /* SIOCGIWENCODE */ - dummy, /* SIOCSIWPOWER */ - rtw_wx_get_power, /* SIOCGIWPOWER */ - NULL, /*---hole---*/ - NULL, /*---hole---*/ - rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ - NULL, /* SIOCGWGENIE */ - rtw_wx_set_auth, /* SIOCSIWAUTH */ - NULL, /* SIOCGIWAUTH */ - rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCGIWENCODEEXT */ - rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ + IW_HANDLER(SIOCGIWNAME, rtw_wx_get_name), + IW_HANDLER(SIOCSIWNWID, dummy), + IW_HANDLER(SIOCGIWNWID, dummy), + IW_HANDLER(SIOCGIWFREQ, rtw_wx_set_freq), + IW_HANDLER(SIOCGIWFREQ, rtw_wx_get_freq), + IW_HANDLER(SIOCSIWMODE, rtw_wx_set_mode), + IW_HANDLER(SIOCGIWMODE, rtw_wx_get_mode), + IW_HANDLER(SIOCSIWSENS, dummy), + IW_HANDLER(SIOCGIWSENS, rtw_wx_get_sens), + IW_HANDLER(SIOCGIWRANGE, rtw_wx_get_range), + IW_HANDLER(SIOCSIWPRIV, rtw_wx_set_priv), + IW_HANDLER(SIOCSIWSPY, dummy), + IW_HANDLER(SIOCGIWSPY, dummy), + IW_HANDLER(SIOCSIWAP, rtw_wx_set_wap), + IW_HANDLER(SIOCGIWAP, rtw_wx_get_wap), + IW_HANDLER(SIOCSIWMLME, rtw_wx_set_mlme), + IW_HANDLER(SIOCGIWAPLIST, dummy), + IW_HANDLER(SIOCSIWSCAN, rtw_wx_set_scan), + IW_HANDLER(SIOCGIWSCAN, rtw_wx_get_scan), + IW_HANDLER(SIOCSIWESSID, rtw_wx_set_essid), + IW_HANDLER(SIOCGIWESSID, rtw_wx_get_essid), + IW_HANDLER(SIOCSIWNICKN, dummy), + IW_HANDLER(SIOCGIWNICKN, rtw_wx_get_nick), + IW_HANDLER(SIOCSIWRATE, rtw_wx_set_rate), + IW_HANDLER(SIOCGIWRATE, rtw_wx_get_rate), + IW_HANDLER(SIOCSIWRTS, rtw_wx_set_rts), + IW_HANDLER(SIOCGIWRTS, rtw_wx_get_rts), + IW_HANDLER(SIOCSIWFRAG, rtw_wx_set_frag), + IW_HANDLER(SIOCGIWFRAG, rtw_wx_get_frag), + IW_HANDLER(SIOCSIWTXPOW, dummy), + IW_HANDLER(SIOCGIWTXPOW, dummy), + IW_HANDLER(SIOCSIWRETRY, dummy), + IW_HANDLER(SIOCGIWRETRY, rtw_wx_get_retry), + IW_HANDLER(SIOCSIWENCODE, rtw_wx_set_enc), + IW_HANDLER(SIOCGIWENCODE, rtw_wx_get_enc), + IW_HANDLER(SIOCSIWPOWER, dummy), + IW_HANDLER(SIOCGIWPOWER, rtw_wx_get_power), + IW_HANDLER(SIOCSIWGENIE, rtw_wx_set_gen_ie), + IW_HANDLER(SIOCSIWAUTH, rtw_wx_set_auth), + IW_HANDLER(SIOCSIWENCODEEXT, rtw_wx_set_enc_ext), + IW_HANDLER(SIOCSIWPMKSA, rtw_wx_set_pmkid), }; From c8fd0937e4ea79822aba3aa7439c0931e3192568 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Aug 2021 15:20:57 +0200 Subject: [PATCH 07/24] replace custom hwaddr_aton_i() with mac_pton() Replace custom hwaddr_aton_i() with mac_pton() in core/ioctl_linux.c and remove the now unused function hwaddr_aton_i(). Link: https://lore.kernel.org/r/20210812132057.22579-1-straube.linux@gmail.com --- os_dep/linux/ioctl_linux.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index b52d6db..ca7643d 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -69,33 +69,6 @@ static const char *const iw_operation_mode[] = { "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" }; -/** - * hwaddr_aton - Convert ASCII string to MAC address - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) - */ -static int hwaddr_aton_i(const char *txt, u8 *addr) -{ - int i; - - for (i = 0; i < 6; i++) { - int a, b; - - a = hex2num_i(*txt++); - if (a < 0) - return -1; - b = hex2num_i(*txt++); - if (b < 0) - return -1; - *addr++ = (a << 4) | b; - if (i < 5 && *txt++ != ':') - return -1; - } - - return 0; -} - static void indicate_wx_custom_event(_adapter *padapter, char *msg) { u8 *buff; @@ -3757,8 +3730,7 @@ static int rtw_get_ap_info(struct net_device *dev, pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - /* if(hwaddr_aton_i(pdata->pointer, bssid)) */ - if (hwaddr_aton_i(data, bssid)) { + if (!mac_pton(data, bssid)) { RTW_INFO("Invalid BSSID '%s'.\n", (u8 *)data); _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); return -EINVAL; From 8d93cdeefa8bbd4f45586c913b0198cc8cbe3fe2 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 12 Aug 2021 13:40:25 -0700 Subject: [PATCH 08/24] Remove unused static inline functions in rtw_recv.h The functions are not used or are called from functions that are not used so just remove them to remove the warnings. Link: https://lore.kernel.org/r/20210812204027.338872-2-nathan@kernel.org --- include/rtw_recv.h | 54 ---------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/include/rtw_recv.h b/include/rtw_recv.h index 3f65e0b..3236dd1 100644 --- a/include/rtw_recv.h +++ b/include/rtw_recv.h @@ -792,22 +792,6 @@ __inline static u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz) } - - -__inline static _buffer *get_rxbuf_desc(union recv_frame *precvframe) -{ - _buffer *buf_desc; - - if (precvframe == NULL) - return NULL; -#ifdef PLATFORM_WINDOWS - NdisQueryPacket(precvframe->u.hdr.pkt, NULL, NULL, &buf_desc, NULL); -#endif - - return buf_desc; -} - - __inline static union recv_frame *rxmem_to_recvframe(u8 *rxmem) { /* due to the design of 2048 bytes alignment of recv_frame, we can reference the union recv_frame */ @@ -818,44 +802,6 @@ __inline static union recv_frame *rxmem_to_recvframe(u8 *rxmem) } -__inline static union recv_frame *pkt_to_recvframe(_pkt *pkt) -{ - - u8 *buf_star; - union recv_frame *precv_frame; -#ifdef PLATFORM_WINDOWS - _buffer *buf_desc; - uint len; - - NdisQueryPacket(pkt, NULL, NULL, &buf_desc, &len); - NdisQueryBufferSafe(buf_desc, &buf_star, &len, HighPagePriority); -#endif - precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); - - return precv_frame; -} - -__inline static u8 *pkt_to_recvmem(_pkt *pkt) -{ - /* return the rx_head */ - - union recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->u.hdr.rx_head; - -} - -__inline static u8 *pkt_to_recvdata(_pkt *pkt) -{ - /* return the rx_data */ - - union recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->u.hdr.rx_data; - -} - - __inline static sint get_recvframe_len(union recv_frame *precvframe) { return precvframe->u.hdr.len; From c597fa83da1df841739e769bdbb95a09ae8a76b7 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 12 Aug 2021 13:40:27 -0700 Subject: [PATCH 09/24] Reorganize error handling in rtw_drv_init() Looking at the error function as a whole, the error handling is odd compared to the rest of the kernel, which prefers to set error codes on goto paths, rather than a global "status" variable which determines the error code at the end of the function and function calls in the case of error. Rearrange the error handling of this function to bring it more inline with how the kernel does it in most cases, which helps readability. Link: https://lore.kernel.org/r/20210812204027.338872-4-nathan@kernel.org Link: https://lore.kernel.org/r/20210813201418.4018631-1-nathan@kernel.org --- os_dep/linux/usb_intf.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 0e9c628..37b6cee 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -1471,7 +1471,6 @@ static void rtw_usb_primary_adapter_deinit(_adapter *padapter) static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) { _adapter *padapter = NULL; - int status = _FAIL; struct dvobj_priv *dvobj; #ifdef CONFIG_CONCURRENT_MODE int i; @@ -1484,8 +1483,8 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf, pdid); - if (dvobj == NULL) { - goto exit; + if (!dvobj) { + goto err; } padapter = rtw_usb_primary_adapter_init(dvobj, pusb_intf); @@ -1534,30 +1533,21 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device #endif - status = _SUCCESS; + return 0; -#if 0 /* not used now */ -os_ndevs_deinit: - if (status != _SUCCESS) - rtw_os_ndevs_deinit(dvobj); -#endif free_if_vir: - if (status != _SUCCESS) { - #ifdef CONFIG_CONCURRENT_MODE - rtw_drv_stop_vir_ifaces(dvobj); - rtw_drv_free_vir_ifaces(dvobj); - #endif - } + #ifdef CONFIG_CONCURRENT_MODE + rtw_drv_stop_vir_ifaces(dvobj); + rtw_drv_free_vir_ifaces(dvobj); + #endif free_if_prim: - if (status != _SUCCESS && padapter) - rtw_usb_primary_adapter_deinit(padapter); + rtw_usb_primary_adapter_deinit(padapter); free_dvobj: - if (status != _SUCCESS) - usb_dvobj_deinit(pusb_intf); -exit: - return status == _SUCCESS ? 0 : -ENODEV; + usb_dvobj_deinit(pusb_intf); +err: + return -ENODEV; } /* From 22a000acb9dd700a6fc43f3e63ac8e37628cabbe Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Sat, 14 Aug 2021 18:08:04 +0200 Subject: [PATCH 10/24] Remove defined but not used variables Remove defined but not used const variables. Issues detected by GCC running with -Wunused-const-variable option enabled. Link: https://lore.kernel.org/r/20210814160804.11634-1-fmdefrancesco@gmail.com --- os_dep/linux/ioctl_linux.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index ca7643d..7b4905c 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -65,10 +65,6 @@ extern u8 convert_ip_addr(u8 hch, u8 mch, u8 lch); u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; -static const char *const iw_operation_mode[] = { - "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" -}; - static void indicate_wx_custom_event(_adapter *padapter, char *msg) { u8 *buff; From c1f70ba056444890355b76c4042ace2f70072b03 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Aug 2021 18:55:18 +0200 Subject: [PATCH 11/24] use common ieee80211 constants Many defined constants in wifi.h are unused and/or available from , some with slightly different names. Remove the constants from wifi.h and use the common ones. Rename where necessary. Link: https://lore.kernel.org/r/20210814165518.8672-1-straube.linux@gmail.com --- core/rtw_ap.c | 20 +++++++------- core/rtw_mlme.c | 10 +++---- core/rtw_mlme_ext.c | 6 ++--- core/rtw_tdls.c | 2 +- include/wifi.h | 53 +------------------------------------- os_dep/linux/ioctl_linux.c | 2 +- 6 files changed, 21 insertions(+), 72 deletions(-) diff --git a/core/rtw_ap.c b/core/rtw_ap.c index ccad5fa..263a6ac 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -1089,10 +1089,10 @@ void update_sta_info_apmode(_adapter *padapter, struct sta_info *psta) /* check if sta supports rx ampdu */ phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; - phtpriv_sta->rx_ampdu_min_spacing = (phtpriv_sta->ht_cap.ampdu_params_info & IEEE80211_HT_CAP_AMPDU_DENSITY) >> 2; + phtpriv_sta->rx_ampdu_min_spacing = (phtpriv_sta->ht_cap.ampdu_params_info & IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; /* bwmode */ - if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH)) + if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) psta->cmn.bw_mode = CHANNEL_WIDTH_40; else psta->cmn.bw_mode = CHANNEL_WIDTH_20; @@ -2271,20 +2271,20 @@ int rtw_check_beacon_data(_adapter *padapter, u8 *pbuf, int len) pht_cap->cap_info &= ~(IEEE80211_HT_CAP_TX_STBC); if (!TEST_FLAG(pmlmepriv->htpriv.stbc_cap, STBC_HT_ENABLE_RX)) - pht_cap->cap_info &= ~(IEEE80211_HT_CAP_RX_STBC_3R); + pht_cap->cap_info &= ~(IEEE80211_HT_CAP_RX_STBC); /* Update A-MPDU Parameters field */ - pht_cap->ampdu_params_info &= ~(IEEE80211_HT_CAP_AMPDU_FACTOR | IEEE80211_HT_CAP_AMPDU_DENSITY); + pht_cap->ampdu_params_info &= ~(IEEE80211_HT_AMPDU_PARM_FACTOR | IEEE80211_HT_AMPDU_PARM_DENSITY); if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) { rtw_hal_get_def_var(padapter, HW_VAR_BEST_AMPDU_DENSITY, &best_ampdu_density); - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & (best_ampdu_density << 2)); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (best_ampdu_density << 2)); } else - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & max_rx_ampdu_factor); /* set Max Rx AMPDU size to 64K */ + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & max_rx_ampdu_factor); /* set Max Rx AMPDU size to 64K */ _rtw_memcpy(&(pmlmeinfo->HT_caps), pht_cap, sizeof(struct HT_caps_element)); @@ -3482,7 +3482,7 @@ int rtw_ht_operation_update(_adapter *padapter) if (pmlmepriv->num_sta_no_ht /*|| (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)*/) new_op_mode = OP_MODE_MIXED; - else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH) + else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40) && pmlmepriv->num_sta_ht_20mhz) new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; else if (atomic_read(&pmlmepriv->olbc_ht)) @@ -3671,7 +3671,7 @@ void bss_cap_update_on_sta_join(_adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_ht_no_gf); } - if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) { if (!psta->ht_20mhz_set) { psta->ht_20mhz_set = 1; pmlmepriv->num_sta_ht_20mhz++; @@ -3682,7 +3682,7 @@ void bss_cap_update_on_sta_join(_adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_ht_20mhz); } - if (((ht_capab & RTW_IEEE80211_HT_CAP_40MHZ_INTOLERANT) != 0) && + if (((ht_capab & IEEE80211_HT_CAP_40MHZ_INTOLERANT) != 0) && (psta->ht_40mhz_intolerant == 0)) { psta->ht_40mhz_intolerant = 1; pmlmepriv->num_sta_40mhz_intolerant++; diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index d0be290..66e7b6d 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -4704,7 +4704,7 @@ unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, ui } if (oper_bw == CHANNEL_WIDTH_40) { - ht_capie.cap_info |= IEEE80211_HT_CAP_SUP_WIDTH; + ht_capie.cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; if (phtpriv->sgi_40m) ht_capie.cap_info |= IEEE80211_HT_CAP_SGI_40; } @@ -4786,7 +4786,7 @@ unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, ui #if defined(CONFIG_RTL8188E) && defined(CONFIG_SDIO_HCI) ht_capie.ampdu_params_info = 2; #else - ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR&0x03); + ht_capie.ampdu_params_info = (IEEE80211_HT_AMPDU_PARM_FACTOR&0x03); #endif */ @@ -4808,10 +4808,10 @@ unsigned int rtw_restructure_ht_ie(_adapter *padapter, u8 *in_ie, u8 *out_ie, ui */ rtw_hal_get_def_var(padapter, HW_VAR_BEST_AMPDU_DENSITY, &best_ampdu_density); - ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & (best_ampdu_density << 2)); + ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (best_ampdu_density << 2)); } else - ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); + ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); } #ifdef CONFIG_BEAMFORMING ht_capie.tx_BF_cap_info = 0; @@ -4906,7 +4906,7 @@ void rtw_update_ht_cap(_adapter *padapter, u8 *pie, uint ie_len, u8 channel) p = rtw_get_ie(pie + sizeof(NDIS_802_11_FIXED_IEs), _HT_CAPABILITY_IE_, &len, ie_len - sizeof(NDIS_802_11_FIXED_IEs)); if (p && len > 0) { pht_capie = (struct rtw_ieee80211_ht_cap *)(p + 2); - max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); + max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); max_ampdu_sz = 1 << (max_ampdu_sz + 3); /* max_ampdu_sz (kbytes); */ /* RTW_INFO("rtw_update_ht_cap(): max_ampdu_sz=%d\n", max_ampdu_sz); */ diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index ed31e1f..4edb354 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -10147,8 +10147,8 @@ static int issue_action_ba(_adapter *padapter, unsigned char *raddr, unsigned ch BA_para_set &= ~IEEE80211_ADDBA_PARAM_TID_MASK; BA_para_set |= (tid << 2) & IEEE80211_ADDBA_PARAM_TID_MASK; - BA_para_set &= ~RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; - BA_para_set |= (size << 6) & RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; + BA_para_set &= ~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK ; + BA_para_set |= (size << 6) & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK ; if (!padapter->registrypriv.wifi_spec) { if (pregpriv->rx_ampdu_amsdu == 0) /* disabled */ @@ -12176,7 +12176,7 @@ void update_sta_info(_adapter *padapter, struct sta_info *psta) psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; - psta->htpriv.rx_ampdu_min_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & IEEE80211_HT_CAP_AMPDU_DENSITY) >> 2; + psta->htpriv.rx_ampdu_min_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; if (support_short_GI(padapter, &(pmlmeinfo->HT_caps), CHANNEL_WIDTH_20)) psta->htpriv.sgi_20m = _TRUE; diff --git a/core/rtw_tdls.c b/core/rtw_tdls.c index 32855a7..43d8c67 100644 --- a/core/rtw_tdls.c +++ b/core/rtw_tdls.c @@ -474,7 +474,7 @@ void rtw_tdls_process_ht_cap(_adapter *padapter, struct sta_info *ptdls_sta, u8 ptdls_sta->htpriv.sgi_40m = _TRUE; /* Bwmode would still followed AP's setting */ - if (ptdls_sta->htpriv.ht_cap.cap_info & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH)) { + if (ptdls_sta->htpriv.ht_cap.cap_info & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) { if (padapter->mlmeextpriv.cur_bwmode >= CHANNEL_WIDTH_40) ptdls_sta->cmn.bw_mode = CHANNEL_WIDTH_40; ptdls_sta->htpriv.ch_offset = padapter->mlmeextpriv.cur_ch_offset; diff --git a/include/wifi.h b/include/wifi.h index 5670c66..558e263 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -796,11 +796,6 @@ struct rtw_ieee80211_bar { } __attribute__((packed)); #endif -/* 802.11 BAR control masks */ -#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 - - #if defined(PLATFORM_LINUX) || defined(CONFIG_RTL8712FW) || defined(PLATFORM_FREEBSD) @@ -974,53 +969,7 @@ typedef enum _HT_CAP_AMPDU_DENSITY { } HT_CAP_AMPDU_DENSITY; /* 802.11n HT capabilities masks */ -#define IEEE80211_HT_CAP_LDPC_CODING 0x0001 -#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 -#define IEEE80211_HT_CAP_SM_PS 0x000C -#define IEEE80211_HT_CAP_GRN_FLD 0x0010 -#define IEEE80211_HT_CAP_SGI_20 0x0020 -#define IEEE80211_HT_CAP_SGI_40 0x0040 -#define IEEE80211_HT_CAP_TX_STBC 0x0080 -#define IEEE80211_HT_CAP_RX_STBC_1R 0x0100 -#define IEEE80211_HT_CAP_RX_STBC_2R 0x0200 -#define IEEE80211_HT_CAP_RX_STBC_3R 0x0300 -#define IEEE80211_HT_CAP_DELAY_BA 0x0400 -#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 -#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 -#define RTW_IEEE80211_HT_CAP_40MHZ_INTOLERANT ((u16) BIT(14)) -/* 802.11n HT capability AMPDU settings */ -#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 -#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C -/* 802.11n HT capability MSC set */ -#define IEEE80211_SUPP_MCS_SET_UEQM 4 -#define IEEE80211_HT_CAP_MAX_STREAMS 4 -#define IEEE80211_SUPP_MCS_SET_LEN 10 -/* maximum streams the spec allows */ -#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 -#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 -#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C -#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 -/* 802.11n HT capability TXBF capability */ -#define IEEE80211_HT_CAP_TXBF_RX_NDP 0x00000008 -#define IEEE80211_HT_CAP_TXBF_TX_NDP 0x00000010 -#define IEEE80211_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP 0x00000400 - -/* 802.11n HT IE masks */ -#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 -#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 -#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 -#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 -#define IEEE80211_HT_IE_CHA_WIDTH 0x04 -#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 -#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 -#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 - -/* block-ack parameters */ -#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 -#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C -#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 -#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 -#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 +#define IEEE80211_HT_CAP_RX_STBC_1R 0x0100 /* * A-PMDU buffer sizes diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 7b4905c..7ea673a 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -463,7 +463,7 @@ static inline char *iwe_stream_rate_process(_adapter *padapter, ht_cap = _TRUE; pht_capie = (struct rtw_ieee80211_ht_cap *)(p + 2); _rtw_memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2); - bw_40MHz = (pht_capie->cap_info & IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + bw_40MHz = (pht_capie->cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0; short_GI = (pht_capie->cap_info & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } } From 76cefd5ae27ba1e23fd7d95471b8bbb3ba9eedee Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 16 Aug 2021 09:34:49 +0200 Subject: [PATCH 12/24] remove inline markings from functions in rtw_br_ext.c The compiler is free to ignore, or follow, "inline" markings so they really have no use in .c files, so just remove them. This allows functions to properly show up as being unused when all callers to them are removed, otherwise gcc does not warn you about this. Link: https://lore.kernel.org/r/20210816073450.668993-1-gregkh@linuxfoundation.org --- core/rtw_br_ext.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index d3fe403..dd11235 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -84,7 +84,7 @@ /* Find a tag in pppoe frame and return the pointer */ -static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) +static unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) { unsigned char *cur_ptr, *start_ptr; unsigned short tagLen, tagType; @@ -102,7 +102,7 @@ static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, un } -static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) +static int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) { struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; @@ -142,7 +142,7 @@ static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) return 0; } -static __inline__ unsigned long __nat25_timeout(_adapter *priv) +static unsigned long __nat25_timeout(_adapter *priv) { unsigned long timeout; @@ -152,7 +152,7 @@ static __inline__ unsigned long __nat25_timeout(_adapter *priv) } -static __inline__ int __nat25_has_expired(_adapter *priv, +static int __nat25_has_expired(_adapter *priv, struct nat25_network_db_entry *fdb) { if (time_before_eq(fdb->ageing_timer, __nat25_timeout(priv))) @@ -162,7 +162,7 @@ static __inline__ int __nat25_has_expired(_adapter *priv, } -static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, +static void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, unsigned int *ipAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -172,7 +172,7 @@ static __inline__ void __nat25_generate_ipv4_network_addr(unsigned char *network } #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) -static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, +static void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -183,7 +183,7 @@ static __inline__ void __nat25_generate_ipx_network_addr_with_node(unsigned char } -static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, +static void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -194,7 +194,7 @@ static __inline__ void __nat25_generate_ipx_network_addr_with_socket(unsigned ch } -static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networkAddr, +static void __nat25_generate_apple_network_addr(unsigned char *networkAddr, unsigned short *network, unsigned char *node) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -205,7 +205,7 @@ static __inline__ void __nat25_generate_apple_network_addr(unsigned char *networ } #endif -static __inline__ void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, +static void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, unsigned char *ac_mac, unsigned short *sid) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -325,7 +325,7 @@ static void convert_ipv6_mac_to_mc(struct sk_buff *skb) #endif /* SUPPORT_RX_UNI2MCAST */ -static __inline__ int __nat25_network_hash(unsigned char *networkAddr) +static int __nat25_network_hash(unsigned char *networkAddr) { if (networkAddr[0] == NAT25_IPV4) { unsigned long x; @@ -377,7 +377,7 @@ static __inline__ int __nat25_network_hash(unsigned char *networkAddr) } -static __inline__ void __network_hash_link(_adapter *priv, +static void __network_hash_link(_adapter *priv, struct nat25_network_db_entry *ent, int hash) { /* Caller must _enter_critical_bh already! */ @@ -394,7 +394,7 @@ static __inline__ void __network_hash_link(_adapter *priv, } -static __inline__ void __network_hash_unlink(struct nat25_network_db_entry *ent) +static void __network_hash_unlink(struct nat25_network_db_entry *ent) { /* Caller must _enter_critical_bh already! */ /* _irqL irqL; */ From 397bbaeacf05b78383afd2e1bf3587943c3789a8 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:47 +0100 Subject: [PATCH 13/24] convert only rtw_vmalloc call to vmalloc Convert the only call to rtw_vmalloc in os_dep/ioctl_linux.c to the kernel's existing vmalloc function, as rtw_malloc is just a preprocessor definition for _rtw_vmalloc. The _rtw_vmalloc function is defined inline and returns a u8, wrapping standard vmalloc. This behaviour is not necessary. Link: https://lore.kernel.org/r/20210818234853.208448-2-phil@philpotter.co.uk --- core/efuse/rtw_efuse.c | 8 ++++---- os_dep/linux/ioctl_linux.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/efuse/rtw_efuse.c b/core/efuse/rtw_efuse.c index e99dd7c..298e26b 100644 --- a/core/efuse/rtw_efuse.c +++ b/core/efuse/rtw_efuse.c @@ -3144,9 +3144,9 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf, int map_size) goto exit; } - file_data = rtw_vmalloc(file_size); + file_data = vmalloc(file_size); if (!file_data) { - RTW_ERR("%s rtw_vmalloc(%d) fail\n", __func__, file_size); + RTW_ERR("%s vmalloc(%d) fail\n", __func__, file_size); goto exit; } @@ -3156,9 +3156,9 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf, int map_size) goto exit; } - map = rtw_vmalloc(map_size); + map = vmalloc(map_size); if (!map) { - RTW_ERR("%s rtw_vmalloc(%d) fail\n", __func__, map_size); + RTW_ERR("%s vmalloc(%d) fail\n", __func__, map_size); goto exit; } memset(map, 0xff, map_size); diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 7ea673a..3dc3c62 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -7838,7 +7838,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; len = dwrq->length; - ext = rtw_vmalloc(len); + ext = vmalloc(len); if (!ext) return -ENOMEM; @@ -7850,7 +7850,7 @@ static int rtw_wx_set_priv(struct net_device *dev, #ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV - ext_dbg = rtw_vmalloc(len); + ext_dbg = vmalloc(len); if (!ext_dbg) { vfree(ext); return -ENOMEM; From 6e2f371df5a48671361885f25b6e5cbcce426162 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:48 +0100 Subject: [PATCH 14/24] remove rtw_vmalloc preprocessor definition Remove rtw_vmalloc preprocessor definition from include/osdep_service.h as it now has no callers. Link: https://lore.kernel.org/r/20210818234853.208448-3-phil@philpotter.co.uk --- include/osdep_service.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index e0afc2d..54139a3 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -168,13 +168,11 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #endif /* CONFIG_USB_HCI */ #ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc(sz) dbg_rtw_vmalloc((sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_zvmalloc(sz) dbg_rtw_zvmalloc((sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_vmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zvmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_vmfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc(sz) dbg_rtw_malloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zvmalloc(sz) dbg_rtw_zmalloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_malloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) @@ -239,13 +237,11 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a #endif /* CONFIG_USB_HCI */ #ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_vmalloc_f(sz, mstat_f) _rtw_vmalloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) #else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc(sz) _rtw_malloc((sz)) #define rtw_zvmalloc(sz) _rtw_zmalloc((sz)) #define rtw_vmalloc_f(sz, mstat_f) _rtw_malloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zmalloc((sz)) From 1f0cf855dc1c4d2051934d3006cda9d801a6c2a2 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:49 +0100 Subject: [PATCH 15/24] remove function _rtw_vmalloc Remove the function _rtw_vmalloc from os_dep/osdep_service.c, converting its only user (also in os_dep/osdep_service.c) to use plain vmalloc. This function is just an inline wrapper around vmalloc which returns a u8 pointer, which isn't needed. Also remove the declaration from include/osdep_service.h. It is considered generally bad practice to declare functions as inline in the majority of cases, as not only can this qualifier be ignored by the compiler but the compiler generally makes good decisions about inlining anyway. Link: https://lore.kernel.org/r/20210818234853.208448-4-phil@philpotter.co.uk --- include/osdep_service.h | 3 +-- os_dep/osdep_service.c | 30 ++---------------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index 54139a3..0fedf0d 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -212,7 +212,6 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #define rtw_mstat_update(flag, status, sz) do {} while (0) #define rtw_mstat_dump(sel) do {} while (0) #define match_mstat_sniff_rules(flags, size) _FALSE -void *_rtw_vmalloc(u32 sz); void *_rtw_zvmalloc(u32 sz); void *_rtw_zmalloc(u32 sz); void *_rtw_malloc(u32 sz); @@ -238,7 +237,7 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a #ifdef CONFIG_USE_VMALLOC #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) -#define rtw_vmalloc_f(sz, mstat_f) _rtw_vmalloc((sz)) +#define rtw_vmalloc_f(sz, mstat_f) vmalloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) #else /* CONFIG_USE_VMALLOC */ diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 3621b6e..1e23cc0 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -65,37 +65,11 @@ u32 rtw_atoi(u8 *s) } -inline void *_rtw_vmalloc(u32 sz) -{ - void *pbuf; -#ifdef PLATFORM_LINUX - pbuf = vmalloc(sz); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_NOWAIT); -#endif - -#ifdef PLATFORM_WINDOWS - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); -#endif - -#ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX - if (pbuf != NULL) { - atomic_inc(&_malloc_cnt); - atomic_add(sz, &_malloc_size); - } -#endif -#endif /* DBG_MEMORY_LEAK */ - - return pbuf; -} - inline void *_rtw_zvmalloc(u32 sz) { void *pbuf; #ifdef PLATFORM_LINUX - pbuf = _rtw_vmalloc(sz); + pbuf = vmalloc(sz); if (pbuf != NULL) memset(pbuf, 0, sz); #endif @@ -547,7 +521,7 @@ inline void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func, if (match_mstat_sniff_rules(flags, sz)) RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - p = _rtw_vmalloc((sz)); + p = vmalloc(sz); rtw_mstat_update( flags From 2a467a7923a5ed19b090b41f43842bbf6bdedd07 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:50 +0100 Subject: [PATCH 16/24] convert all rtw_zvmalloc calls to vzalloc calls Convert all rtw_zvmalloc calls within the driver to use the existing kernel vzalloc function, which has the same semantics. Also rewrite the two places where it is mentioned in comments to say vzalloc, and remove the redundant cast to struct adapter * in ./os_dep/usb_intf.c as vzalloc returns void *. The reason for the conversion is that rtw_zvmalloc is just a preprocessor definition for _rtw_zvmalloc which itself is just an inline wrapper around vmalloc which then zeroes the memory out. As vzalloc does the same thing via usage of __GFP_ZERO, this code is redundant and can subsequently be removed. Link: https://lore.kernel.org/r/20210818234853.208448-5-phil@philpotter.co.uk --- core/mesh/rtw_mesh.c | 2 +- core/rtw_mlme.c | 4 ++-- core/rtw_mlme_ext.c | 2 +- core/rtw_mp.c | 2 +- core/rtw_recv.c | 4 ++-- core/rtw_rf.c | 2 +- core/rtw_sta_mgt.c | 2 +- core/rtw_xmit.c | 10 +++++----- hal/hal_com.c | 6 +++--- hal/hal_com_phycfg.c | 14 +++++++------- hal/hal_halmac.c | 2 +- hal/hal_intf.c | 2 +- hal/phydm/phydm_interface.c | 4 ++-- os_dep/linux/os_intfs.c | 4 ++-- os_dep/linux/usb_intf.c | 2 +- os_dep/osdep_service.c | 2 +- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/core/mesh/rtw_mesh.c b/core/mesh/rtw_mesh.c index 1d51b54..1c12a6c 100644 --- a/core/mesh/rtw_mesh.c +++ b/core/mesh/rtw_mesh.c @@ -1077,7 +1077,7 @@ void dump_mesh_networks(void *sel, _adapter *adapter) u8 mesh_network_cnt = 0; int i; - mesh_networks = rtw_zvmalloc(mlme->max_bss_cnt * sizeof(struct wlan_network *)); + mesh_networks = vzalloc(mlme->max_bss_cnt * sizeof(struct wlan_network *)); if (!mesh_networks) return; diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index 66e7b6d..5a1f552 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -47,7 +47,7 @@ sint _rtw_init_mlme_priv(_adapter *padapter) sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ @@ -82,7 +82,7 @@ sint _rtw_init_mlme_priv(_adapter *padapter) pmlmepriv->max_bss_cnt = MAX_BSS_CNT + MAX_BSS_CNT; - pbuf = rtw_zvmalloc(pmlmepriv->max_bss_cnt * (sizeof(struct wlan_network))); + pbuf = vzalloc(pmlmepriv->max_bss_cnt * (sizeof(struct wlan_network))); if (pbuf == NULL) { res = _FAIL; diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 4edb354..eee4dfb 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -1130,7 +1130,7 @@ int init_mlme_ext_priv(_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ pmlmeext->padapter = padapter; diff --git a/core/rtw_mp.c b/core/rtw_mp.c index 9175f6a..2309e0c 100644 --- a/core/rtw_mp.c +++ b/core/rtw_mp.c @@ -2505,7 +2505,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmit_extbuf == NULL) { res = _FAIL; diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 71f477b..aa26039 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -80,7 +80,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, _adapter *padapter) sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ _rtw_spinlock_init(&precvpriv->lock); @@ -110,7 +110,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, _adapter *padapter) rtw_os_recv_resource_init(precvpriv, padapter); - precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) { res = _FAIL; diff --git a/core/rtw_rf.c b/core/rtw_rf.c index b74e2e5..d8667bc 100644 --- a/core/rtw_rf.c +++ b/core/rtw_rf.c @@ -1056,7 +1056,7 @@ void rtw_txpwr_lmt_add_with_nlen(struct rf_ctl_t *rfctl, const char *regd_name, } /* alloc new one */ - ent = (struct txpwr_lmt_ent *)rtw_zvmalloc(sizeof(struct txpwr_lmt_ent) + nlen + 1); + ent = (struct txpwr_lmt_ent *)vzalloc(sizeof(struct txpwr_lmt_ent) + nlen + 1); if (!ent) goto release_lock; diff --git a/core/rtw_sta_mgt.c b/core/rtw_sta_mgt.c index c26d50f..86873d0 100644 --- a/core/rtw_sta_mgt.c +++ b/core/rtw_sta_mgt.c @@ -237,7 +237,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) pstapriv->padapter = adapter; - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); if (!pstapriv->pallocated_stainfo_buf) goto exit; diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 9c9f569..5212fdf 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -71,7 +71,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter) sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ _rtw_spinlock_init(&pxmitpriv->lock); @@ -104,7 +104,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter) Please also apply free_txobj to link_up all the xmit_frames... */ - pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); if (pxmitpriv->pallocated_frame_buf == NULL) { pxmitpriv->pxmit_frame_buf = NULL; @@ -142,7 +142,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter) _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmitbuf == NULL) { res = _FAIL; @@ -194,7 +194,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter) /* init xframe_ext queue, the same count as extbuf */ _rtw_init_queue(&pxmitpriv->free_xframe_ext_queue); - pxmitpriv->xframe_ext_alloc_addr = rtw_zvmalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4); + pxmitpriv->xframe_ext_alloc_addr = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4); if (pxmitpriv->xframe_ext_alloc_addr == NULL) { pxmitpriv->xframe_ext = NULL; @@ -226,7 +226,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, _adapter *padapter) /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmit_extbuf == NULL) { res = _FAIL; diff --git a/hal/hal_com.c b/hal/hal_com.c index d0cb0b3..505cc8c 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -4696,7 +4696,7 @@ void rtw_dump_rsvd_page(void *sel, _adapter *adapter, u8 page_offset, u8 page_nu rtw_hal_get_def_var(adapter, HAL_DEF_TX_PAGE_SIZE, &page_size); if (page_size) { buf_size = page_size * page_num; - buffer = rtw_zvmalloc(buf_size); + buffer = vzalloc(buf_size); if (buffer) { rtw_hal_get_rsvd_page(adapter, page_offset, page_num, buffer, buf_size); @@ -4729,7 +4729,7 @@ void rtw_dump_fifo(void *sel, _adapter *adapter, u8 fifo_sel, u32 fifo_addr, u32 if (fifo_size) { buff_size = RND4(fifo_size); - buffer = rtw_zvmalloc(buff_size); + buffer = vzalloc(buff_size); if (buffer == NULL) buff_size = 0; } @@ -5190,7 +5190,7 @@ static void rtw_hal_get_aoac_rpt(_adapter *adapter) rtw_hal_get_def_var(adapter, HAL_DEF_TX_PAGE_SIZE, &page_size); buf_size = page_size * page_number; - buffer = rtw_zvmalloc(buf_size); + buffer = vzalloc(buf_size); if (buffer == NULL) { RTW_ERR("%s buffer allocate failed size(%d)\n", diff --git a/hal/hal_com_phycfg.c b/hal/hal_com_phycfg.c index 6424101..98a8b76 100644 --- a/hal/hal_com_phycfg.c +++ b/hal/hal_com_phycfg.c @@ -4092,7 +4092,7 @@ phy_ConfigMACWithParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pHalData->mac_reg = rtw_zvmalloc(rlen); + pHalData->mac_reg = vzalloc(rlen); if (pHalData->mac_reg) { _rtw_memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen); pHalData->mac_reg_len = rlen; @@ -4171,7 +4171,7 @@ phy_ConfigBBWithParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pBuf = rtw_zvmalloc(rlen); + pBuf = vzalloc(rlen); if (pBuf) { _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen); *pBufLen = rlen; @@ -4477,7 +4477,7 @@ phy_ConfigBBWithPgParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pHalData->bb_phy_reg_pg = rtw_zvmalloc(rlen); + pHalData->bb_phy_reg_pg = vzalloc(rlen); if (pHalData->bb_phy_reg_pg) { _rtw_memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen); pHalData->bb_phy_reg_pg_len = rlen; @@ -4526,7 +4526,7 @@ phy_ConfigBBWithMpParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pHalData->bb_phy_reg_mp = rtw_zvmalloc(rlen); + pHalData->bb_phy_reg_mp = vzalloc(rlen); if (pHalData->bb_phy_reg_mp) { _rtw_memcpy(pHalData->bb_phy_reg_mp, pHalData->para_file_buf, rlen); pHalData->bb_phy_reg_mp_len = rlen; @@ -4630,7 +4630,7 @@ PHY_ConfigRFWithParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pBuf = rtw_zvmalloc(rlen); + pBuf = vzalloc(rlen); if (pBuf) { _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen); *pBufLen = rlen; @@ -4829,7 +4829,7 @@ PHY_ConfigRFWithTxPwrTrackParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_track = rtw_zvmalloc(rlen); + pHalData->rf_tx_pwr_track = vzalloc(rlen); if (pHalData->rf_tx_pwr_track) { _rtw_memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen); pHalData->rf_tx_pwr_track_len = rlen; @@ -5328,7 +5328,7 @@ PHY_ConfigRFWithPowerLimitTableParaFile( rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); if (rlen > 0) { rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_lmt = rtw_zvmalloc(rlen); + pHalData->rf_tx_pwr_lmt = vzalloc(rlen); if (pHalData->rf_tx_pwr_lmt) { _rtw_memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen); pHalData->rf_tx_pwr_lmt_len = rlen; diff --git a/hal/hal_halmac.c b/hal/hal_halmac.c index 907e487..cb6a1a6 100644 --- a/hal/hal_halmac.c +++ b/hal/hal_halmac.c @@ -4388,7 +4388,7 @@ int rtw_halmac_dump_fifo(struct dvobj_priv *d, u8 fifo_sel, u32 addr, u32 size, fifo_size = api->halmac_get_fifo_size(mac, halmac_fifo_sel); if (fifo_size) - pfifo_map = rtw_zvmalloc(fifo_size); + pfifo_map = vzalloc(fifo_size); if (pfifo_map == NULL) return -1; mem_created = _TRUE; diff --git a/hal/hal_intf.c b/hal/hal_intf.c index bdfeb4e..9f52d0c 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -147,7 +147,7 @@ u8 rtw_hal_data_init(_adapter *padapter) { if (is_primary_adapter(padapter)) { padapter->hal_data_sz = sizeof(HAL_DATA_TYPE); - padapter->HalData = rtw_zvmalloc(padapter->hal_data_sz); + padapter->HalData = vzalloc(padapter->hal_data_sz); if (padapter->HalData == NULL) { RTW_INFO("cant not alloc memory for HAL DATA\n"); return _FAIL; diff --git a/hal/phydm/phydm_interface.c b/hal/phydm/phydm_interface.c index 6cdb3f6..028c4b5 100644 --- a/hal/phydm/phydm_interface.c +++ b/hal/phydm/phydm_interface.c @@ -370,12 +370,12 @@ void odm_allocate_memory(struct dm_struct *dm, void **ptr, u32 length) #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2) *ptr = kmalloc(length, GFP_ATOMIC); #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) - *ptr = rtw_zvmalloc(length); + *ptr = vzalloc(length); #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN) void *adapter = dm->adapter; PlatformAllocateMemory(adapter, ptr, length); #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT) - *ptr = rtw_zvmalloc(length); + *ptr = vzalloc(length); #endif } diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 3632c4d..fee8204 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -2396,7 +2396,7 @@ u8 rtw_init_drv_sw(_adapter *padapter) /* add for CONFIG_IEEE80211W, none 11w also can use */ _rtw_spinlock_init(&padapter->security_key_mutex); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ /* memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); */ if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) { @@ -2805,7 +2805,7 @@ _adapter *rtw_drv_add_vir_if(_adapter *primary_padapter, u8 mac[ETH_ALEN]; /****** init adapter ******/ - padapter = (_adapter *)rtw_zvmalloc(sizeof(*padapter)); + padapter = (_adapter *)vzalloc(sizeof(*padapter)); if (padapter == NULL) goto exit; diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index 37b6cee..87b9d56 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -1270,7 +1270,7 @@ _adapter *rtw_usb_primary_adapter_init(struct dvobj_priv *dvobj, _adapter *padapter = NULL; int status = _FAIL; - padapter = (_adapter *)rtw_zvmalloc(sizeof(*padapter)); + padapter = (_adapter *)vzalloc(sizeof(*padapter)); if (padapter == NULL) goto exit; diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 1e23cc0..d5e9c87 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2028,7 +2028,7 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) pnpi = netdev_priv(pnetdev); - pnpi->priv = rtw_zvmalloc(sizeof_priv); + pnpi->priv = vzalloc(sizeof_priv); if (!pnpi->priv) { free_netdev(pnetdev); pnetdev = NULL; From 9f0e896c3502e196fccf3ac5483d6f656f4815fc Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:51 +0100 Subject: [PATCH 17/24] remove rtw_zvmalloc preprocessor definition Remove rtw_zvmalloc preprocessor definition from include/osdep_service.h as it now has no callers. Link: https://lore.kernel.org/r/20210818234853.208448-6-phil@philpotter.co.uk --- include/osdep_service.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index 0fedf0d..585870a 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -168,12 +168,10 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #endif /* CONFIG_USB_HCI */ #ifdef CONFIG_USE_VMALLOC -#define rtw_zvmalloc(sz) dbg_rtw_zvmalloc((sz), MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_vmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zvmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_vmfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) #else /* CONFIG_USE_VMALLOC */ -#define rtw_zvmalloc(sz) dbg_rtw_zmalloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_malloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_mfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) @@ -236,12 +234,10 @@ void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_a #endif /* CONFIG_USB_HCI */ #ifdef CONFIG_USE_VMALLOC -#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_vmalloc_f(sz, mstat_f) vmalloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) #else /* CONFIG_USE_VMALLOC */ -#define rtw_zvmalloc(sz) _rtw_zmalloc((sz)) #define rtw_vmalloc_f(sz, mstat_f) _rtw_malloc((sz)) #define rtw_zvmalloc_f(sz, mstat_f) _rtw_zmalloc((sz)) #define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_mfree((pbuf), (sz)) From 3255bcf09375f7c72993b4ee871bb0517ad2f698 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:52 +0100 Subject: [PATCH 18/24] remove function _rtw_zvmalloc Remove the function _rtw_zvmalloc from os_dep/osdep_service.c, as this function is now unused and is just an inline wrapper around vmalloc which zeroes out the memory. All previous callers have been converted to use vzalloc. Also remove the declaration from include/osdep_service.h. It is considered generally bad practice to declare functions as inline in the majority of cases, as not only can this qualifier be ignored by the compiler but the compiler generally makes good decisions about inlining anyway. Link: https://lore.kernel.org/r/20210818234853.208448-7-phil@philpotter.co.uk --- include/osdep_service.h | 25 ------------------ os_dep/osdep_service.c | 56 ----------------------------------------- 2 files changed, 81 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index 585870a..6fc4ae0 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -106,10 +106,6 @@ extern int RTW_STATUS_CODE(int error_code); -#ifndef RTK_DMP_PLATFORM - #define CONFIG_USE_VMALLOC -#endif - /* flags used for rtw_mstat_update() */ enum mstat_f { /* type: 0x00ff */ @@ -143,8 +139,6 @@ typedef enum mstat_status { void rtw_mstat_update(const enum mstat_f flags, const MSTAT_STATUS status, u32 sz); void rtw_mstat_dump(void *sel); bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size); -void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); -void *dbg_rtw_zvmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void dbg_rtw_vmfree(void *pbuf, const enum mstat_f flags, u32 sz, const char *func, const int line); void *dbg_rtw_malloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void *dbg_rtw_zmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); @@ -167,15 +161,6 @@ void *dbg_rtw_usb_buffer_alloc(struct usb_device *dev, size_t size, dma_addr_t * void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma, const enum mstat_f flags, const char *func, const int line); #endif /* CONFIG_USB_HCI */ -#ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_vmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zvmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_vmfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_VIR, __FUNCTION__, __LINE__) -#else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc_f(sz, mstat_f) dbg_rtw_malloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#define rtw_zvmalloc_f(sz, mstat_f) dbg_rtw_zmalloc((sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#define rtw_vmfree_f(pbuf, sz, mstat_f) dbg_rtw_mfree((pbuf), (sz), ((mstat_f) & 0xff00) | MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) -#endif /* CONFIG_USE_VMALLOC */ #define rtw_malloc(sz) dbg_rtw_malloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_zmalloc(sz) dbg_rtw_zmalloc((sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) #define rtw_mfree(pbuf, sz) dbg_rtw_mfree((pbuf), (sz), MSTAT_TYPE_PHY, __FUNCTION__, __LINE__) @@ -210,7 +195,6 @@ void dbg_rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dm #define rtw_mstat_update(flag, status, sz) do {} while (0) #define rtw_mstat_dump(sel) do {} while (0) #define match_mstat_sniff_rules(flags, size) _FALSE -void *_rtw_zvmalloc(u32 sz); void *_rtw_zmalloc(u32 sz); void *_rtw_malloc(u32 sz); void _rtw_mfree(void *pbuf, u32 sz); @@ -233,15 +217,6 @@ void *_rtw_usb_buffer_alloc(struct usb_device *dev, size_t size, dma_addr_t *dma void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma); #endif /* CONFIG_USB_HCI */ -#ifdef CONFIG_USE_VMALLOC -#define rtw_vmalloc_f(sz, mstat_f) vmalloc((sz)) -#define rtw_zvmalloc_f(sz, mstat_f) _rtw_zvmalloc((sz)) -#define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_vmfree((pbuf), (sz)) -#else /* CONFIG_USE_VMALLOC */ -#define rtw_vmalloc_f(sz, mstat_f) _rtw_malloc((sz)) -#define rtw_zvmalloc_f(sz, mstat_f) _rtw_zmalloc((sz)) -#define rtw_vmfree_f(pbuf, sz, mstat_f) _rtw_mfree((pbuf), (sz)) -#endif /* CONFIG_USE_VMALLOC */ #define rtw_malloc(sz) _rtw_malloc((sz)) #define rtw_zmalloc(sz) _rtw_zmalloc((sz)) #define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index d5e9c87..d3714a8 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -65,26 +65,6 @@ u32 rtw_atoi(u8 *s) } -inline void *_rtw_zvmalloc(u32 sz) -{ - void *pbuf; -#ifdef PLATFORM_LINUX - pbuf = vmalloc(sz); - if (pbuf != NULL) - memset(pbuf, 0, sz); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_ZERO | M_NOWAIT); -#endif -#ifdef PLATFORM_WINDOWS - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); - if (pbuf != NULL) - NdisFillMemory(pbuf, sz, 0); -#endif - - return pbuf; -} - void *_rtw_malloc(u32 sz) { void *pbuf = NULL; @@ -514,42 +494,6 @@ bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size) return _FALSE; } -inline void *dbg_rtw_vmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line) -{ - void *p; - - if (match_mstat_sniff_rules(flags, sz)) - RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - - p = vmalloc(sz); - - rtw_mstat_update( - flags - , p ? MSTAT_ALLOC_SUCCESS : MSTAT_ALLOC_FAIL - , sz - ); - - return p; -} - -inline void *dbg_rtw_zvmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line) -{ - void *p; - - if (match_mstat_sniff_rules(flags, sz)) - RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - - p = _rtw_zvmalloc((sz)); - - rtw_mstat_update( - flags - , p ? MSTAT_ALLOC_SUCCESS : MSTAT_ALLOC_FAIL - , sz - ); - - return p; -} - inline void dbg_rtw_vmfree(void *pbuf, u32 sz, const enum mstat_f flags, const char *func, const int line) { From f218547ef9b9f93d3a60f88fba36dc4ea6f3ca98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Garc=C3=A9s?= Date: Mon, 11 Oct 2021 16:12:48 +0200 Subject: [PATCH 19/24] Remove unused debug function --- include/osdep_service.h | 1 - os_dep/osdep_service.c | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/include/osdep_service.h b/include/osdep_service.h index 6fc4ae0..8fc0ab2 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -139,7 +139,6 @@ typedef enum mstat_status { void rtw_mstat_update(const enum mstat_f flags, const MSTAT_STATUS status, u32 sz); void rtw_mstat_dump(void *sel); bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size); -void dbg_rtw_vmfree(void *pbuf, const enum mstat_f flags, u32 sz, const char *func, const int line); void *dbg_rtw_malloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void *dbg_rtw_zmalloc(u32 sz, const enum mstat_f flags, const char *func, const int line); void dbg_rtw_mfree(void *pbuf, const enum mstat_f flags, u32 sz, const char *func, const int line); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index d3714a8..010eae3 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -494,21 +494,6 @@ bool match_mstat_sniff_rules(const enum mstat_f flags, const size_t size) return _FALSE; } -inline void dbg_rtw_vmfree(void *pbuf, u32 sz, const enum mstat_f flags, const char *func, const int line) -{ - - if (match_mstat_sniff_rules(flags, sz)) - RTW_INFO("DBG_MEM_ALLOC %s:%d %s(%d)\n", func, line, __FUNCTION__, (sz)); - - vfree((pbuf)); - - rtw_mstat_update( - flags - , MSTAT_FREE - , sz - ); -} - inline void *dbg_rtw_malloc(u32 sz, const enum mstat_f flags, const char *func, const int line) { void *p; From 64831e67779cb5325bc8d46921ac51d5d868c4c1 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:51 +0200 Subject: [PATCH 20/24] staging: r8188eu: remove unused define _HCI_OPS_OS_C_ is not used in the r8188eu driver. Remove it. Link: https://lore.kernel.org/r/20210821164859.4351-2-martin@kaiser.cx --- hal/rtl8192e/usb/usb_ops_linux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hal/rtl8192e/usb/usb_ops_linux.c b/hal/rtl8192e/usb/usb_ops_linux.c index 69efc36..03031bf 100644 --- a/hal/rtl8192e/usb/usb_ops_linux.c +++ b/hal/rtl8192e/usb/usb_ops_linux.c @@ -12,7 +12,6 @@ * more details. * *****************************************************************************/ -#define _HCI_OPS_OS_C_ /* #include */ #include From 28e0bba7940a6c4f06163d14214c5389129324c4 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 18 Aug 2021 22:00:40 +0200 Subject: [PATCH 21/24] ctrl vendor req value is always 0x05 The bRequest value for the vendor specific control requests sent by this driver is always 0x05. Replace the function parameter with the define from usb_ops.h. This patch is an adaptation of commit eeb4661560ff ("staging: rtl8188eu: ctrl vendor req value is always 0x05") for the new r8188eu driver. Link: https://lore.kernel.org/r/20210818200041.10870-1-martin@kaiser.cx --- hal/hal_hci/hal_usb.c | 35 +++++++---------------------------- include/usb_ops_linux.h | 2 +- os_dep/linux/usb_ops_linux.c | 4 ++-- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index f802a3f..7961a82 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -319,7 +319,6 @@ int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -327,7 +326,6 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u8 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -340,8 +338,7 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -349,7 +346,6 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -357,7 +353,6 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u16 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -370,8 +365,7 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -380,7 +374,6 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -388,7 +381,6 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) u32 data = 0; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ @@ -401,8 +393,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return data; @@ -410,7 +401,6 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -419,7 +409,6 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -433,8 +422,7 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -442,7 +430,6 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -451,7 +438,6 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -465,8 +451,7 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -475,7 +460,6 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -484,7 +468,6 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -498,8 +481,7 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; @@ -508,7 +490,6 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -517,15 +498,13 @@ int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = length; _rtw_memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, - buf, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, buf, len, requesttype); return ret; diff --git a/include/usb_ops_linux.h b/include/usb_ops_linux.h index 3ec6ac4..41c634d 100644 --- a/include/usb_ops_linux.h +++ b/include/usb_ops_linux.h @@ -60,7 +60,7 @@ void usb_read_port_cancel(struct intf_hdl *pintfhdl); u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); void usb_write_port_cancel(struct intf_hdl *pintfhdl); -int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); +int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); #ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype); diff --git a/os_dep/linux/usb_ops_linux.c b/os_dep/linux/usb_ops_linux.c index 62b6f22..a126472 100644 --- a/os_dep/linux/usb_ops_linux.c +++ b/os_dep/linux/usb_ops_linux.c @@ -23,7 +23,7 @@ struct rtw_async_write_data { struct usb_ctrlrequest dr; }; -int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { _adapter *padapter = pintfhdl->padapter; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); @@ -106,7 +106,7 @@ int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 inde _rtw_memcpy(pIo_buf, pdata, len); } - status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_io_error(pdvobjpriv); From ba036a3e1425330fe786118851288546d285c7bc Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:55 +0200 Subject: [PATCH 22/24] clean up the usb_readXY functions Remove unnecessary variables, summarize declarations and assignments. Link: https://lore.kernel.org/r/20210821164859.4351-6-martin@kaiser.cx --- hal/hal_hci/hal_usb.c | 45 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index 7961a82..196e204 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -319,18 +319,9 @@ int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; + u16 wvalue = (u16)(addr & 0x0000ffff); u8 data = 0; - - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 1; /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) @@ -338,7 +329,7 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 1, VENDOR_READ); return data; @@ -346,26 +337,16 @@ u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u16 data = 0; + u16 wvalue = (u16)(addr & 0x0000ffff); + u16 data; - - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 2; - /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) if(wvalue >= 0x0000 && wvalue < 0x0100) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 2, VENDOR_READ); return data; @@ -374,18 +355,8 @@ u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u32 data = 0; - - - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 4; + u16 wvalue = (u16)(addr & 0x0000ffff); + u32 data; /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) @@ -393,7 +364,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue |= 0x8000; #endif - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 4, VENDOR_READ); return data; From fe504c75a2827a00bfb18ac63f8ee5aaa5e5097b Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:56 +0200 Subject: [PATCH 23/24] clean up the usb_writeXY functions Remove unnecessary variables, summarize declarations and assignments. Link: https://lore.kernel.org/r/20210821164859.4351-7-martin@kaiser.cx --- hal/hal_hci/hal_usb.c | 59 +++++-------------------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index 196e204..664d0ee 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -372,20 +372,7 @@ u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u8 data; - int ret; - - - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 1; - data = val; + u16 wvalue = (u16)(addr & 0x0000ffff); /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) @@ -393,28 +380,13 @@ int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 1, VENDOR_WRITE); - - return ret; } int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u16 data; - int ret; - - - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 2; - data = val; + u16 wvalue = (u16)(addr & 0x0000ffff); /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) @@ -422,29 +394,13 @@ int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); - - - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 2, VENDOR_WRITE); } int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u32 data; - int ret; - - - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr & 0x0000ffff); - len = 4; - data = val; + u16 wvalue = (u16)(addr & 0x0000ffff); /* WLANON PAGE0_REG needs to add an offset 0x8000 */ #if defined(CONFIG_RTL8710B) @@ -452,10 +408,7 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) wvalue |= 0x8000; #endif - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); - - - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 4, VENDOR_WRITE); } From d4dcb38048b5a7c8f7918dcba97b169cc6227e6f Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:57 +0200 Subject: [PATCH 24/24] clean up the usb_writeN Remove unnecessary variables, check the length. Link: https://lore.kernel.org/r/20210821164859.4351-8-martin@kaiser.cx --- hal/hal_hci/hal_usb.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/hal/hal_hci/hal_usb.c b/hal/hal_hci/hal_usb.c index 664d0ee..1f87797 100644 --- a/hal/hal_hci/hal_usb.c +++ b/hal/hal_hci/hal_usb.c @@ -414,24 +414,15 @@ int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; + u16 wvalue = (u16)(addr & 0x0000ffff); u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; - int ret; + if (length > VENDOR_CMD_MAX_DATA_LEN) + return -EINVAL; - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ + memcpy(buf, pdata, length); + return usbctrl_vendorreq(pintfhdl, wvalue, 0, buf, (length & 0xffff), VENDOR_WRITE); - wvalue = (u16)(addr & 0x0000ffff); - len = length; - _rtw_memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, buf, len, requesttype); - - - return ret; } void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops)