aboutsummaryrefslogtreecommitdiffstats
path: root/package/libertas/src/11d.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/libertas/src/11d.c')
-rw-r--r--package/libertas/src/11d.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/package/libertas/src/11d.c b/package/libertas/src/11d.c
index 5e10ce0d35..40f1daadb5 100644
--- a/package/libertas/src/11d.c
+++ b/package/libertas/src/11d.c
@@ -46,11 +46,13 @@ static struct chan_freq_power channel_freq_power_UN_BG[] = {
static u8 lbs_region_2_code(u8 *region)
{
u8 i;
+ u8 size = sizeof(region_code_mapping)/
+ sizeof(struct region_code_mapping);
for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++)
region[i] = toupper(region[i]);
- for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
+ for (i = 0; i < size; i++) {
if (!memcmp(region, region_code_mapping[i].region,
COUNTRY_CODE_LEN))
return (region_code_mapping[i].code);
@@ -63,8 +65,9 @@ static u8 lbs_region_2_code(u8 *region)
static u8 *lbs_code_2_region(u8 code)
{
u8 i;
-
- for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
+ u8 size = sizeof(region_code_mapping)
+ / sizeof(struct region_code_mapping);
+ for (i = 0; i < size; i++) {
if (region_code_mapping[i].code == code)
return (region_code_mapping[i].region);
}
@@ -87,7 +90,8 @@ static u8 lbs_get_chan_11d(u8 band, u8 firstchan, u8 nrchan, u8 *chan)
u8 cfp_no;
cfp = channel_freq_power_UN_BG;
- cfp_no = ARRAY_SIZE(channel_freq_power_UN_BG);
+ cfp_no = sizeof(channel_freq_power_UN_BG) /
+ sizeof(struct chan_freq_power);
for (i = 0; i < cfp_no; i++) {
if ((cfp + i)->channel == firstchan) {
@@ -137,12 +141,16 @@ static u8 lbs_channel_known_11d(u8 chan,
u32 lbs_chan_2_freq(u8 chan, u8 band)
{
struct chan_freq_power *cf;
+ u16 cnt;
u16 i;
u32 freq = 0;
cf = channel_freq_power_UN_BG;
+ cnt =
+ sizeof(channel_freq_power_UN_BG) /
+ sizeof(struct chan_freq_power);
- for (i = 0; i < ARRAY_SIZE(channel_freq_power_UN_BG); i++) {
+ for (i = 0; i < cnt; i++) {
if (chan == cf[i].channel)
freq = cf[i].freq;
}