diff options
author | David Kilroy <kilroyd@googlemail.com> | 2008-12-23 09:03:38 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 15:58:46 -0500 |
commit | 9ee677c2276bfcbcf68042ec2718a504af0c5fd7 (patch) | |
tree | 0b5528241690e143c60832d319ddbb2ad1c5d7f1 /drivers/net/wireless/orinoco | |
parent | eaee7cc2c180c291084a1c1f49cd2bf13002b3e1 (diff) |
wireless: Add channel/frequency conversions to ieee80211.h
Added mappings for FHSS, DSSS and OFDM channels - with macros to point
HR DSSS and ERP to the DSSS mappings. Currently just static inline
functions.
Use the new functions in the older fullmac drivers. This eliminates a
number of const static buffers and removes a couple of range checks that
are now redundant.
Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Richard Farina <sidhayn@gmail.com>
Acked-by: Jeroen Vreeken <pe1rxq@amsat.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco')
-rw-r--r-- | drivers/net/wireless/orinoco/orinoco.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/net/wireless/orinoco/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c index 45a04faa7818..beb4d1f8c184 100644 --- a/drivers/net/wireless/orinoco/orinoco.c +++ b/drivers/net/wireless/orinoco/orinoco.c | |||
@@ -178,12 +178,7 @@ static const struct ethtool_ops orinoco_ethtool_ops; | |||
178 | /* Data tables */ | 178 | /* Data tables */ |
179 | /********************************************************************/ | 179 | /********************************************************************/ |
180 | 180 | ||
181 | /* The frequency of each channel in MHz */ | 181 | #define NUM_CHANNELS 14 |
182 | static const long channel_frequency[] = { | ||
183 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, | ||
184 | 2447, 2452, 2457, 2462, 2467, 2472, 2484 | ||
185 | }; | ||
186 | #define NUM_CHANNELS ARRAY_SIZE(channel_frequency) | ||
187 | 182 | ||
188 | /* This tables gives the actual meanings of the bitrate IDs returned | 183 | /* This tables gives the actual meanings of the bitrate IDs returned |
189 | * by the firmware. */ | 184 | * by the firmware. */ |
@@ -3742,13 +3737,13 @@ static int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, | |||
3742 | return err; | 3737 | return err; |
3743 | } | 3738 | } |
3744 | 3739 | ||
3745 | static long orinoco_hw_get_freq(struct orinoco_private *priv) | 3740 | static int orinoco_hw_get_freq(struct orinoco_private *priv) |
3746 | { | 3741 | { |
3747 | 3742 | ||
3748 | hermes_t *hw = &priv->hw; | 3743 | hermes_t *hw = &priv->hw; |
3749 | int err = 0; | 3744 | int err = 0; |
3750 | u16 channel; | 3745 | u16 channel; |
3751 | long freq = 0; | 3746 | int freq = 0; |
3752 | unsigned long flags; | 3747 | unsigned long flags; |
3753 | 3748 | ||
3754 | if (orinoco_lock(priv, &flags) != 0) | 3749 | if (orinoco_lock(priv, &flags) != 0) |
@@ -3771,7 +3766,7 @@ static long orinoco_hw_get_freq(struct orinoco_private *priv) | |||
3771 | goto out; | 3766 | goto out; |
3772 | 3767 | ||
3773 | } | 3768 | } |
3774 | freq = channel_frequency[channel-1] * 100000; | 3769 | freq = ieee80211_dsss_chan_to_freq(channel); |
3775 | 3770 | ||
3776 | out: | 3771 | out: |
3777 | orinoco_unlock(priv, &flags); | 3772 | orinoco_unlock(priv, &flags); |
@@ -3998,7 +3993,8 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev, | |||
3998 | for (i = 0; i < NUM_CHANNELS; i++) { | 3993 | for (i = 0; i < NUM_CHANNELS; i++) { |
3999 | if (priv->channel_mask & (1 << i)) { | 3994 | if (priv->channel_mask & (1 << i)) { |
4000 | range->freq[k].i = i + 1; | 3995 | range->freq[k].i = i + 1; |
4001 | range->freq[k].m = channel_frequency[i] * 100000; | 3996 | range->freq[k].m = (ieee80211_dsss_chan_to_freq(i + 1) * |
3997 | 100000); | ||
4002 | range->freq[k].e = 1; | 3998 | range->freq[k].e = 1; |
4003 | k++; | 3999 | k++; |
4004 | } | 4000 | } |
@@ -4346,16 +4342,15 @@ static int orinoco_ioctl_setfreq(struct net_device *dev, | |||
4346 | /* Setting by channel number */ | 4342 | /* Setting by channel number */ |
4347 | chan = frq->m; | 4343 | chan = frq->m; |
4348 | } else { | 4344 | } else { |
4349 | /* Setting by frequency - search the table */ | 4345 | /* Setting by frequency */ |
4350 | int mult = 1; | 4346 | int denom = 1; |
4351 | int i; | 4347 | int i; |
4352 | 4348 | ||
4349 | /* Calculate denominator to rescale to MHz */ | ||
4353 | for (i = 0; i < (6 - frq->e); i++) | 4350 | for (i = 0; i < (6 - frq->e); i++) |
4354 | mult *= 10; | 4351 | denom *= 10; |
4355 | 4352 | ||
4356 | for (i = 0; i < NUM_CHANNELS; i++) | 4353 | chan = ieee80211_freq_to_dsss_chan(frq->m / denom); |
4357 | if (frq->m == (channel_frequency[i] * mult)) | ||
4358 | chan = i+1; | ||
4359 | } | 4354 | } |
4360 | 4355 | ||
4361 | if ( (chan < 1) || (chan > NUM_CHANNELS) || | 4356 | if ( (chan < 1) || (chan > NUM_CHANNELS) || |
@@ -4392,7 +4387,7 @@ static int orinoco_ioctl_getfreq(struct net_device *dev, | |||
4392 | return tmp; | 4387 | return tmp; |
4393 | } | 4388 | } |
4394 | 4389 | ||
4395 | frq->m = tmp; | 4390 | frq->m = tmp * 100000; |
4396 | frq->e = 1; | 4391 | frq->e = 1; |
4397 | 4392 | ||
4398 | return 0; | 4393 | return 0; |
@@ -5609,7 +5604,7 @@ static inline char *orinoco_translate_scan(struct net_device *dev, | |||
5609 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | 5604 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
5610 | &iwe, IW_EV_FREQ_LEN); | 5605 | &iwe, IW_EV_FREQ_LEN); |
5611 | 5606 | ||
5612 | iwe.u.freq.m = channel_frequency[channel-1] * 100000; | 5607 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; |
5613 | iwe.u.freq.e = 1; | 5608 | iwe.u.freq.e = 1; |
5614 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | 5609 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
5615 | &iwe, IW_EV_FREQ_LEN); | 5610 | &iwe, IW_EV_FREQ_LEN); |
@@ -5760,7 +5755,7 @@ static inline char *orinoco_translate_ext_scan(struct net_device *dev, | |||
5760 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | 5755 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
5761 | &iwe, IW_EV_FREQ_LEN); | 5756 | &iwe, IW_EV_FREQ_LEN); |
5762 | 5757 | ||
5763 | iwe.u.freq.m = channel_frequency[channel-1] * 100000; | 5758 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; |
5764 | iwe.u.freq.e = 1; | 5759 | iwe.u.freq.e = 1; |
5765 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | 5760 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, |
5766 | &iwe, IW_EV_FREQ_LEN); | 5761 | &iwe, IW_EV_FREQ_LEN); |