diff options
author | Alejandro Martinez Ruiz <alex@flawedcode.org> | 2007-10-18 04:16:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:03:37 -0500 |
commit | c00acf46deb18926931ba264510353cf22b98a79 (patch) | |
tree | 7b7105d3505cb13aa0474e0bd89b23d7b9f2b958 /drivers/net/wireless/libertas/11d.c | |
parent | 4c3616cdda0632a3d0e39069765f9ea0e6bd093e (diff) |
netdev: ARRAY_SIZE() cleanups
Convert array size calculations to use ARRAY_SIZE().
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/wireless/libertas/11d.c')
-rw-r--r-- | drivers/net/wireless/libertas/11d.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/net/wireless/libertas/11d.c b/drivers/net/wireless/libertas/11d.c index 9cf0211de67f..8bbd3227e6fb 100644 --- a/drivers/net/wireless/libertas/11d.c +++ b/drivers/net/wireless/libertas/11d.c | |||
@@ -46,13 +46,11 @@ static struct chan_freq_power channel_freq_power_UN_BG[] = { | |||
46 | static u8 wlan_region_2_code(u8 * region) | 46 | static u8 wlan_region_2_code(u8 * region) |
47 | { | 47 | { |
48 | u8 i; | 48 | u8 i; |
49 | u8 size = sizeof(region_code_mapping)/ | ||
50 | sizeof(struct region_code_mapping); | ||
51 | 49 | ||
52 | for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++) | 50 | for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++) |
53 | region[i] = toupper(region[i]); | 51 | region[i] = toupper(region[i]); |
54 | 52 | ||
55 | for (i = 0; i < size; i++) { | 53 | for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) { |
56 | if (!memcmp(region, region_code_mapping[i].region, | 54 | if (!memcmp(region, region_code_mapping[i].region, |
57 | COUNTRY_CODE_LEN)) | 55 | COUNTRY_CODE_LEN)) |
58 | return (region_code_mapping[i].code); | 56 | return (region_code_mapping[i].code); |
@@ -65,9 +63,8 @@ static u8 wlan_region_2_code(u8 * region) | |||
65 | static u8 *wlan_code_2_region(u8 code) | 63 | static u8 *wlan_code_2_region(u8 code) |
66 | { | 64 | { |
67 | u8 i; | 65 | u8 i; |
68 | u8 size = sizeof(region_code_mapping) | 66 | |
69 | / sizeof(struct region_code_mapping); | 67 | for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) { |
70 | for (i = 0; i < size; i++) { | ||
71 | if (region_code_mapping[i].code == code) | 68 | if (region_code_mapping[i].code == code) |
72 | return (region_code_mapping[i].region); | 69 | return (region_code_mapping[i].region); |
73 | } | 70 | } |
@@ -90,8 +87,7 @@ static u8 wlan_get_chan_11d(u8 band, u8 firstchan, u8 nrchan, u8 * chan) | |||
90 | u8 cfp_no; | 87 | u8 cfp_no; |
91 | 88 | ||
92 | cfp = channel_freq_power_UN_BG; | 89 | cfp = channel_freq_power_UN_BG; |
93 | cfp_no = sizeof(channel_freq_power_UN_BG) / | 90 | cfp_no = ARRAY_SIZE(channel_freq_power_UN_BG); |
94 | sizeof(struct chan_freq_power); | ||
95 | 91 | ||
96 | for (i = 0; i < cfp_no; i++) { | 92 | for (i = 0; i < cfp_no; i++) { |
97 | if ((cfp + i)->channel == firstchan) { | 93 | if ((cfp + i)->channel == firstchan) { |
@@ -141,16 +137,12 @@ static u8 wlan_channel_known_11d(u8 chan, | |||
141 | u32 libertas_chan_2_freq(u8 chan, u8 band) | 137 | u32 libertas_chan_2_freq(u8 chan, u8 band) |
142 | { | 138 | { |
143 | struct chan_freq_power *cf; | 139 | struct chan_freq_power *cf; |
144 | u16 cnt; | ||
145 | u16 i; | 140 | u16 i; |
146 | u32 freq = 0; | 141 | u32 freq = 0; |
147 | 142 | ||
148 | cf = channel_freq_power_UN_BG; | 143 | cf = channel_freq_power_UN_BG; |
149 | cnt = | ||
150 | sizeof(channel_freq_power_UN_BG) / | ||
151 | sizeof(struct chan_freq_power); | ||
152 | 144 | ||
153 | for (i = 0; i < cnt; i++) { | 145 | for (i = 0; i < ARRAY_SIZE(channel_freq_power_UN_BG); i++) { |
154 | if (chan == cf[i].channel) | 146 | if (chan == cf[i].channel) |
155 | freq = cf[i].freq; | 147 | freq = cf[i].freq; |
156 | } | 148 | } |
@@ -664,8 +656,7 @@ int libertas_create_dnld_countryinfo_11d(wlan_private * priv) | |||
664 | if (priv->adapter->enable11d) { | 656 | if (priv->adapter->enable11d) { |
665 | /* update parsed_region_chan_11; dnld domaininf to FW */ | 657 | /* update parsed_region_chan_11; dnld domaininf to FW */ |
666 | 658 | ||
667 | for (j = 0; j < sizeof(adapter->region_channel) / | 659 | for (j = 0; j < ARRAY_SIZE(adapter->region_channel); j++) { |
668 | sizeof(adapter->region_channel[0]); j++) { | ||
669 | region_chan = &adapter->region_channel[j]; | 660 | region_chan = &adapter->region_channel[j]; |
670 | 661 | ||
671 | lbs_deb_11d("%d region_chan->band %d\n", j, | 662 | lbs_deb_11d("%d region_chan->band %d\n", j, |
@@ -679,8 +670,7 @@ int libertas_create_dnld_countryinfo_11d(wlan_private * priv) | |||
679 | break; | 670 | break; |
680 | } | 671 | } |
681 | 672 | ||
682 | if (j >= sizeof(adapter->region_channel) / | 673 | if (j >= ARRAY_SIZE(adapter->region_channel)) { |
683 | sizeof(adapter->region_channel[0])) { | ||
684 | lbs_deb_11d("region_chan not found, band %d\n", | 674 | lbs_deb_11d("region_chan not found, band %d\n", |
685 | adapter->curbssparams.band); | 675 | adapter->curbssparams.band); |
686 | ret = -1; | 676 | ret = -1; |