diff options
author | Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> | 2017-10-01 15:30:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-03 18:34:57 +0200 |
commit | 60db8d10ee3339840d88e57605276bb568af6031 (patch) | |
tree | e5093170ab3ac17a0745a1c282a2ac1c2e82d27c /drivers/staging/rtl8723bs/core | |
parent | staging: rtlwifi: use ARRAY_SIZE (diff) | |
download | linux-dev-60db8d10ee3339840d88e57605276bb568af6031.tar.xz linux-dev-60db8d10ee3339840d88e57605276bb568af6031.zip |
staging: rtl8723bs: 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: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8723bs/core')
-rw-r--r-- | drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 | ||||
-rw-r--r-- | drivers/staging/rtl8723bs/core/rtw_rf.c | 7 |
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 9f0921b2779a..355ce9b19d1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -17,6 +17,7 @@ #include <drv_types.h> #include <rtw_debug.h> #include <rtw_wifi_regd.h> +#include <linux/kernel.h> static struct mlme_handler mlme_sta_tbl[] = { @@ -559,7 +560,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) index = GetFrameSubType(pframe) >> 4; - if (index >= (sizeof(mlme_sta_tbl) / sizeof(struct mlme_handler))) { + if (index >= ARRAY_SIZE(mlme_sta_tbl)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index)); return; } @@ -2224,7 +2225,7 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) category = frame_body[0]; - for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) { ptable = &OnAction_tbl[i]; if (category == ptable->num) diff --git a/drivers/staging/rtl8723bs/core/rtw_rf.c b/drivers/staging/rtl8723bs/core/rtw_rf.c index b87ea4e388c0..07f5577cc073 100644 --- a/drivers/staging/rtl8723bs/core/rtw_rf.c +++ b/drivers/staging/rtl8723bs/core/rtw_rf.c @@ -15,6 +15,7 @@ #define _RTW_RF_C_ #include <drv_types.h> +#include <linux/kernel.h> struct ch_freq { @@ -44,20 +45,18 @@ static struct ch_freq ch_freq_map[] = { {216, 5080},/* Japan, means J16 */ }; -static int ch_freq_map_num = (sizeof(ch_freq_map) / sizeof(struct ch_freq)); - u32 rtw_ch2freq(u32 channel) { u8 i; u32 freq = 0; - for (i = 0; i < ch_freq_map_num; i++) { + for (i = 0; i < ARRAY_SIZE(ch_freq_map); i++) { if (channel == ch_freq_map[i].channel) { freq = ch_freq_map[i].frequency; break; } } - if (i == ch_freq_map_num) + if (i == ARRAY_SIZE(ch_freq_map)) freq = 2412; return freq; |