Commit 53ac7935 authored by Jérémy Lefaure's avatar Jérémy Lefaure Committed by Kalle Valo

wireless: use ARRAY_SIZE

Using the ARRAY_SIZE macro improves the readability of the code. Also,
it is not always useful to use a variable to store this constant
calculated at compile time.

Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
 (sizeof(E)@p /sizeof(*E))
|
 (sizeof(E)@p /sizeof(E[...]))
|
 (sizeof(E)@p /sizeof(T))
)
Signed-off-by: default avatarJérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 59365b9e
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "../pwrseqcmd.h" #include "../pwrseqcmd.h"
#include "pwrseq.h" #include "pwrseq.h"
#include "../btcoexist/rtl_btc.h" #include "../btcoexist/rtl_btc.h"
#include <linux/kernel.h>
#define LLT_CONFIG 5 #define LLT_CONFIG 5
...@@ -2126,28 +2127,28 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw, ...@@ -2126,28 +2127,28 @@ static void _rtl8723be_read_adapter_info(struct ieee80211_hw *hw,
if (rtlhal->oem_id == RT_CID_DEFAULT) { if (rtlhal->oem_id == RT_CID_DEFAULT) {
/* Does this one have a Toshiba SMID from group 1? */ /* Does this one have a Toshiba SMID from group 1? */
for (i = 0; i < sizeof(toshiba_smid1) / sizeof(u16); i++) { for (i = 0; i < ARRAY_SIZE(toshiba_smid1); i++) {
if (rtlefuse->eeprom_smid == toshiba_smid1[i]) { if (rtlefuse->eeprom_smid == toshiba_smid1[i]) {
is_toshiba_smid1 = true; is_toshiba_smid1 = true;
break; break;
} }
} }
/* Does this one have a Toshiba SMID from group 2? */ /* Does this one have a Toshiba SMID from group 2? */
for (i = 0; i < sizeof(toshiba_smid2) / sizeof(u16); i++) { for (i = 0; i < ARRAY_SIZE(toshiba_smid2); i++) {
if (rtlefuse->eeprom_smid == toshiba_smid2[i]) { if (rtlefuse->eeprom_smid == toshiba_smid2[i]) {
is_toshiba_smid2 = true; is_toshiba_smid2 = true;
break; break;
} }
} }
/* Does this one have a Samsung SMID? */ /* Does this one have a Samsung SMID? */
for (i = 0; i < sizeof(samsung_smid) / sizeof(u16); i++) { for (i = 0; i < ARRAY_SIZE(samsung_smid); i++) {
if (rtlefuse->eeprom_smid == samsung_smid[i]) { if (rtlefuse->eeprom_smid == samsung_smid[i]) {
is_samsung_smid = true; is_samsung_smid = true;
break; break;
} }
} }
/* Does this one have a Lenovo SMID? */ /* Does this one have a Lenovo SMID? */
for (i = 0; i < sizeof(lenovo_smid) / sizeof(u16); i++) { for (i = 0; i < ARRAY_SIZE(lenovo_smid); i++) {
if (rtlefuse->eeprom_smid == lenovo_smid[i]) { if (rtlefuse->eeprom_smid == lenovo_smid[i]) {
is_lenovo_smid = true; is_lenovo_smid = true;
break; break;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "../rtl8723com/dm_common.h" #include "../rtl8723com/dm_common.h"
#include "table.h" #include "table.h"
#include "trx.h" #include "trx.h"
#include <linux/kernel.h>
static bool _rtl8723be_phy_bb8723b_config_parafile(struct ieee80211_hw *hw); static bool _rtl8723be_phy_bb8723b_config_parafile(struct ieee80211_hw *hw);
static bool _rtl8723be_phy_config_mac_with_headerfile(struct ieee80211_hw *hw); static bool _rtl8723be_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
...@@ -1143,14 +1144,13 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) ...@@ -1143,14 +1144,13 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel)
DESC92C_RATEMCS2, DESC92C_RATEMCS3, DESC92C_RATEMCS2, DESC92C_RATEMCS3,
DESC92C_RATEMCS4, DESC92C_RATEMCS5, DESC92C_RATEMCS4, DESC92C_RATEMCS5,
DESC92C_RATEMCS6, DESC92C_RATEMCS7}; DESC92C_RATEMCS6, DESC92C_RATEMCS7};
u8 i, size; u8 i;
u8 power_index; u8 power_index;
if (!rtlefuse->txpwr_fromeprom) if (!rtlefuse->txpwr_fromeprom)
return; return;
size = sizeof(cck_rates) / sizeof(u8); for (i = 0; i < ARRAY_SIZE(cck_rates); i++) {
for (i = 0; i < size; i++) {
power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A, power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A,
cck_rates[i], cck_rates[i],
rtl_priv(hw)->phy.current_chan_bw, rtl_priv(hw)->phy.current_chan_bw,
...@@ -1158,8 +1158,7 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) ...@@ -1158,8 +1158,7 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel)
_rtl8723be_phy_set_txpower_index(hw, power_index, RF90_PATH_A, _rtl8723be_phy_set_txpower_index(hw, power_index, RF90_PATH_A,
cck_rates[i]); cck_rates[i]);
} }
size = sizeof(ofdm_rates) / sizeof(u8); for (i = 0; i < ARRAY_SIZE(ofdm_rates); i++) {
for (i = 0; i < size; i++) {
power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A, power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A,
ofdm_rates[i], ofdm_rates[i],
rtl_priv(hw)->phy.current_chan_bw, rtl_priv(hw)->phy.current_chan_bw,
...@@ -1167,8 +1166,7 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) ...@@ -1167,8 +1166,7 @@ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel)
_rtl8723be_phy_set_txpower_index(hw, power_index, RF90_PATH_A, _rtl8723be_phy_set_txpower_index(hw, power_index, RF90_PATH_A,
ofdm_rates[i]); ofdm_rates[i]);
} }
size = sizeof(ht_rates_1t) / sizeof(u8); for (i = 0; i < ARRAY_SIZE(ht_rates_1t); i++) {
for (i = 0; i < size; i++) {
power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A, power_index = _rtl8723be_get_txpower_index(hw, RF90_PATH_A,
ht_rates_1t[i], ht_rates_1t[i],
rtl_priv(hw)->phy.current_chan_bw, rtl_priv(hw)->phy.current_chan_bw,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* *
*****************************************************************************/ *****************************************************************************/
#include <linux/kernel.h>
#include "table.h" #include "table.h"
u32 RTL8723BEPHY_REG_1TARRAY[] = { u32 RTL8723BEPHY_REG_1TARRAY[] = {
...@@ -224,8 +225,7 @@ u32 RTL8723BEPHY_REG_1TARRAY[] = { ...@@ -224,8 +225,7 @@ u32 RTL8723BEPHY_REG_1TARRAY[] = {
}; };
u32 RTL8723BEPHY_REG_1TARRAYLEN = u32 RTL8723BEPHY_REG_1TARRAYLEN = ARRAY_SIZE(RTL8723BEPHY_REG_1TARRAY);
sizeof(RTL8723BEPHY_REG_1TARRAY) / sizeof(u32);
u32 RTL8723BEPHY_REG_ARRAY_PG[] = { u32 RTL8723BEPHY_REG_ARRAY_PG[] = {
0, 0, 0, 0x00000e08, 0x0000ff00, 0x00003800, 0, 0, 0, 0x00000e08, 0x0000ff00, 0x00003800,
...@@ -236,8 +236,7 @@ u32 RTL8723BEPHY_REG_ARRAY_PG[] = { ...@@ -236,8 +236,7 @@ u32 RTL8723BEPHY_REG_ARRAY_PG[] = {
0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436 0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436
}; };
u32 RTL8723BEPHY_REG_ARRAY_PGLEN = u32 RTL8723BEPHY_REG_ARRAY_PGLEN = ARRAY_SIZE(RTL8723BEPHY_REG_ARRAY_PG);
sizeof(RTL8723BEPHY_REG_ARRAY_PG) / sizeof(u32);
u32 RTL8723BE_RADIOA_1TARRAY[] = { u32 RTL8723BE_RADIOA_1TARRAY[] = {
0x000, 0x00010000, 0x000, 0x00010000,
...@@ -373,8 +372,7 @@ u32 RTL8723BE_RADIOA_1TARRAY[] = { ...@@ -373,8 +372,7 @@ u32 RTL8723BE_RADIOA_1TARRAY[] = {
}; };
u32 RTL8723BE_RADIOA_1TARRAYLEN = u32 RTL8723BE_RADIOA_1TARRAYLEN = ARRAY_SIZE(RTL8723BE_RADIOA_1TARRAY);
sizeof(RTL8723BE_RADIOA_1TARRAY) / sizeof(u32);
u32 RTL8723BEMAC_1T_ARRAY[] = { u32 RTL8723BEMAC_1T_ARRAY[] = {
0x02F, 0x00000030, 0x02F, 0x00000030,
...@@ -483,7 +481,7 @@ u32 RTL8723BEMAC_1T_ARRAY[] = { ...@@ -483,7 +481,7 @@ u32 RTL8723BEMAC_1T_ARRAY[] = {
}; };
u32 RTL8723BEMAC_1T_ARRAYLEN = sizeof(RTL8723BEMAC_1T_ARRAY) / sizeof(u32); u32 RTL8723BEMAC_1T_ARRAYLEN = ARRAY_SIZE(RTL8723BEMAC_1T_ARRAY);
u32 RTL8723BEAGCTAB_1TARRAY[] = { u32 RTL8723BEAGCTAB_1TARRAY[] = {
0xC78, 0xFD000001, 0xC78, 0xFD000001,
...@@ -620,4 +618,4 @@ u32 RTL8723BEAGCTAB_1TARRAY[] = { ...@@ -620,4 +618,4 @@ u32 RTL8723BEAGCTAB_1TARRAY[] = {
}; };
u32 RTL8723BEAGCTAB_1TARRAYLEN = sizeof(RTL8723BEAGCTAB_1TARRAY) / sizeof(u32); u32 RTL8723BEAGCTAB_1TARRAYLEN = ARRAY_SIZE(RTL8723BEAGCTAB_1TARRAY);
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* Larry Finger <Larry.Finger@lwfinger.net> * Larry Finger <Larry.Finger@lwfinger.net>
* *
*****************************************************************************/ *****************************************************************************/
#include <linux/kernel.h>
#include "table.h" #include "table.h"
u32 RTL8812AE_PHY_REG_ARRAY[] = { u32 RTL8812AE_PHY_REG_ARRAY[] = {
0x800, 0x8020D010, 0x800, 0x8020D010,
...@@ -258,8 +258,7 @@ u32 RTL8812AE_PHY_REG_ARRAY[] = { ...@@ -258,8 +258,7 @@ u32 RTL8812AE_PHY_REG_ARRAY[] = {
0xEB8, 0x00508242, 0xEB8, 0x00508242,
}; };
u32 RTL8812AE_PHY_REG_1TARRAYLEN = u32 RTL8812AE_PHY_REG_1TARRAYLEN = ARRAY_SIZE(RTL8812AE_PHY_REG_ARRAY);
sizeof(RTL8812AE_PHY_REG_ARRAY) / sizeof(u32);
u32 RTL8821AE_PHY_REG_ARRAY[] = { u32 RTL8821AE_PHY_REG_ARRAY[] = {
0x800, 0x0020D090, 0x800, 0x0020D090,
...@@ -436,8 +435,7 @@ u32 RTL8821AE_PHY_REG_ARRAY[] = { ...@@ -436,8 +435,7 @@ u32 RTL8821AE_PHY_REG_ARRAY[] = {
0xCB8, 0x00508240, 0xCB8, 0x00508240,
}; };
u32 RTL8821AE_PHY_REG_1TARRAYLEN = u32 RTL8821AE_PHY_REG_1TARRAYLEN = ARRAY_SIZE(RTL8821AE_PHY_REG_ARRAY);
sizeof(RTL8821AE_PHY_REG_ARRAY) / sizeof(u32);
u32 RTL8812AE_PHY_REG_ARRAY_PG[] = { u32 RTL8812AE_PHY_REG_ARRAY_PG[] = {
0, 0, 0, 0x00000c20, 0xffffffff, 0x34363840, 0, 0, 0, 0x00000c20, 0xffffffff, 0x34363840,
...@@ -488,8 +486,7 @@ u32 RTL8812AE_PHY_REG_ARRAY_PG[] = { ...@@ -488,8 +486,7 @@ u32 RTL8812AE_PHY_REG_ARRAY_PG[] = {
1, 1, 1, 0x00000e4c, 0xffffffff, 0x22242628 1, 1, 1, 0x00000e4c, 0xffffffff, 0x22242628
}; };
u32 RTL8812AE_PHY_REG_ARRAY_PGLEN = u32 RTL8812AE_PHY_REG_ARRAY_PGLEN = ARRAY_SIZE(RTL8812AE_PHY_REG_ARRAY_PG);
sizeof(RTL8812AE_PHY_REG_ARRAY_PG) / sizeof(u32);
u32 RTL8821AE_PHY_REG_ARRAY_PG[] = { u32 RTL8821AE_PHY_REG_ARRAY_PG[] = {
0, 0, 0, 0x00000c20, 0xffffffff, 0x32343638, 0, 0, 0, 0x00000c20, 0xffffffff, 0x32343638,
...@@ -509,8 +506,7 @@ u32 RTL8821AE_PHY_REG_ARRAY_PG[] = { ...@@ -509,8 +506,7 @@ u32 RTL8821AE_PHY_REG_ARRAY_PG[] = {
1, 0, 0, 0x00000c44, 0x0000ffff, 0x00002022 1, 0, 0, 0x00000c44, 0x0000ffff, 0x00002022
}; };
u32 RTL8821AE_PHY_REG_ARRAY_PGLEN = u32 RTL8821AE_PHY_REG_ARRAY_PGLEN = ARRAY_SIZE(RTL8821AE_PHY_REG_ARRAY_PG);
sizeof(RTL8821AE_PHY_REG_ARRAY_PG) / sizeof(u32);
u32 RTL8812AE_RADIOA_ARRAY[] = { u32 RTL8812AE_RADIOA_ARRAY[] = {
0x000, 0x00010000, 0x000, 0x00010000,
...@@ -927,7 +923,7 @@ u32 RTL8812AE_RADIOA_ARRAY[] = { ...@@ -927,7 +923,7 @@ u32 RTL8812AE_RADIOA_ARRAY[] = {
0x018, 0x0001712A, 0x018, 0x0001712A,
}; };
u32 RTL8812AE_RADIOA_1TARRAYLEN = sizeof(RTL8812AE_RADIOA_ARRAY) / sizeof(u32); u32 RTL8812AE_RADIOA_1TARRAYLEN = ARRAY_SIZE(RTL8812AE_RADIOA_ARRAY);
u32 RTL8812AE_RADIOB_ARRAY[] = { u32 RTL8812AE_RADIOB_ARRAY[] = {
0x056, 0x00051CF2, 0x056, 0x00051CF2,
...@@ -1335,7 +1331,7 @@ u32 RTL8812AE_RADIOB_ARRAY[] = { ...@@ -1335,7 +1331,7 @@ u32 RTL8812AE_RADIOB_ARRAY[] = {
0x008, 0x00008400, 0x008, 0x00008400,
}; };
u32 RTL8812AE_RADIOB_1TARRAYLEN = sizeof(RTL8812AE_RADIOB_ARRAY) / sizeof(u32); u32 RTL8812AE_RADIOB_1TARRAYLEN = ARRAY_SIZE(RTL8812AE_RADIOB_ARRAY);
u32 RTL8821AE_RADIOA_ARRAY[] = { u32 RTL8821AE_RADIOA_ARRAY[] = {
0x018, 0x0001712A, 0x018, 0x0001712A,
...@@ -1929,7 +1925,7 @@ u32 RTL8821AE_RADIOA_ARRAY[] = { ...@@ -1929,7 +1925,7 @@ u32 RTL8821AE_RADIOA_ARRAY[] = {
}; };
u32 RTL8821AE_RADIOA_1TARRAYLEN = sizeof(RTL8821AE_RADIOA_ARRAY) / sizeof(u32); u32 RTL8821AE_RADIOA_1TARRAYLEN = ARRAY_SIZE(RTL8821AE_RADIOA_ARRAY);
u32 RTL8812AE_MAC_REG_ARRAY[] = { u32 RTL8812AE_MAC_REG_ARRAY[] = {
0x010, 0x0000000C, 0x010, 0x0000000C,
...@@ -2041,7 +2037,7 @@ u32 RTL8812AE_MAC_REG_ARRAY[] = { ...@@ -2041,7 +2037,7 @@ u32 RTL8812AE_MAC_REG_ARRAY[] = {
0x718, 0x00000040, 0x718, 0x00000040,
}; };
u32 RTL8812AE_MAC_1T_ARRAYLEN = sizeof(RTL8812AE_MAC_REG_ARRAY) / sizeof(u32); u32 RTL8812AE_MAC_1T_ARRAYLEN = ARRAY_SIZE(RTL8812AE_MAC_REG_ARRAY);
u32 RTL8821AE_MAC_REG_ARRAY[] = { u32 RTL8821AE_MAC_REG_ARRAY[] = {
0x428, 0x0000000A, 0x428, 0x0000000A,
...@@ -2143,7 +2139,7 @@ u32 RTL8821AE_MAC_REG_ARRAY[] = { ...@@ -2143,7 +2139,7 @@ u32 RTL8821AE_MAC_REG_ARRAY[] = {
0x718, 0x00000040, 0x718, 0x00000040,
}; };
u32 RTL8821AE_MAC_1T_ARRAYLEN = sizeof(RTL8821AE_MAC_REG_ARRAY) / sizeof(u32); u32 RTL8821AE_MAC_1T_ARRAYLEN = ARRAY_SIZE(RTL8821AE_MAC_REG_ARRAY);
u32 RTL8812AE_AGC_TAB_ARRAY[] = { u32 RTL8812AE_AGC_TAB_ARRAY[] = {
0x80000001, 0x00000000, 0x40000000, 0x00000000, 0x80000001, 0x00000000, 0x40000000, 0x00000000,
...@@ -2479,8 +2475,7 @@ u32 RTL8812AE_AGC_TAB_ARRAY[] = { ...@@ -2479,8 +2475,7 @@ u32 RTL8812AE_AGC_TAB_ARRAY[] = {
0xE50, 0x00000020, 0xE50, 0x00000020,
}; };
u32 RTL8812AE_AGC_TAB_1TARRAYLEN = u32 RTL8812AE_AGC_TAB_1TARRAYLEN = ARRAY_SIZE(RTL8812AE_AGC_TAB_ARRAY);
sizeof(RTL8812AE_AGC_TAB_ARRAY) / sizeof(u32);
u32 RTL8821AE_AGC_TAB_ARRAY[] = { u32 RTL8821AE_AGC_TAB_ARRAY[] = {
0x81C, 0xBF000001, 0x81C, 0xBF000001,
...@@ -2676,8 +2671,7 @@ u32 RTL8821AE_AGC_TAB_ARRAY[] = { ...@@ -2676,8 +2671,7 @@ u32 RTL8821AE_AGC_TAB_ARRAY[] = {
0xC50, 0x00000020, 0xC50, 0x00000020,
}; };
u32 RTL8821AE_AGC_TAB_1TARRAYLEN = u32 RTL8821AE_AGC_TAB_1TARRAYLEN = ARRAY_SIZE(RTL8821AE_AGC_TAB_ARRAY);
sizeof(RTL8821AE_AGC_TAB_ARRAY) / sizeof(u32);
/****************************************************************************** /******************************************************************************
* TXPWR_LMT.TXT * TXPWR_LMT.TXT
...@@ -3250,7 +3244,7 @@ u8 *RTL8812AE_TXPWR_LMT[] = { ...@@ -3250,7 +3244,7 @@ u8 *RTL8812AE_TXPWR_LMT[] = {
"MKK", "5G", "80M", "VHT", "2T", "155", "63" "MKK", "5G", "80M", "VHT", "2T", "155", "63"
}; };
u32 RTL8812AE_TXPWR_LMT_ARRAY_LEN = sizeof(RTL8812AE_TXPWR_LMT) / sizeof(u8 *); u32 RTL8812AE_TXPWR_LMT_ARRAY_LEN = ARRAY_SIZE(RTL8812AE_TXPWR_LMT);
u8 *RTL8821AE_TXPWR_LMT[] = { u8 *RTL8821AE_TXPWR_LMT[] = {
"FCC", "2.4G", "20M", "CCK", "1T", "01", "32", "FCC", "2.4G", "20M", "CCK", "1T", "01", "32",
...@@ -3819,4 +3813,4 @@ u8 *RTL8821AE_TXPWR_LMT[] = { ...@@ -3819,4 +3813,4 @@ u8 *RTL8821AE_TXPWR_LMT[] = {
"MKK", "5G", "80M", "VHT", "2T", "155", "63" "MKK", "5G", "80M", "VHT", "2T", "155", "63"
}; };
u32 RTL8821AE_TXPWR_LMT_ARRAY_LEN = sizeof(RTL8821AE_TXPWR_LMT) / sizeof(u8 *); u32 RTL8821AE_TXPWR_LMT_ARRAY_LEN = ARRAY_SIZE(RTL8821AE_TXPWR_LMT);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment