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/rtw_rf.c | |
parent | 2595587d7e227a9181750110f50e02a2511821dd (diff) |
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/rtw_rf.c')
-rw-r--r-- | drivers/staging/rtl8723bs/core/rtw_rf.c | 7 |
1 files changed, 3 insertions, 4 deletions
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; |