aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ipw2200.c
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2006-02-28 10:48:28 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-17 14:01:34 -0500
commit1867b117d944ce333e79b9a61c9a048656bee14b (patch)
tree068a78c91f1cf9f7b491afa08a1877e278cc3beb /drivers/net/wireless/ipw2200.c
parentdd288e7d75b9041f79fecae77d61cfa345da7266 (diff)
[PATCH] Remove duplicated code from ipw2200.c
As stated in a comment, the ipw2200 driver uses several routines that were borrowed from ieee80211_geo.c. As ipw2200 requires ieee80211, these routines are duplicated. The attached patch, which is sent as an attachment to preserve whitespace, converts ipw2200.c to use the ieee80211 versions, thereby reducing bloat in both the source and binary. Signed-Off-By: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ipw2200.c')
-rw-r--r--drivers/net/wireless/ipw2200.c128
1 files changed, 16 insertions, 112 deletions
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index ed37141319ea..77932cf85008 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -153,12 +153,6 @@ static int init_supported_rates(struct ipw_priv *priv,
153static void ipw_set_hwcrypto_keys(struct ipw_priv *); 153static void ipw_set_hwcrypto_keys(struct ipw_priv *);
154static void ipw_send_wep_keys(struct ipw_priv *, int); 154static void ipw_send_wep_keys(struct ipw_priv *, int);
155 155
156static int ipw_is_valid_channel(struct ieee80211_device *, u8);
157static int ipw_channel_to_index(struct ieee80211_device *, u8);
158static u8 ipw_freq_to_channel(struct ieee80211_device *, u32);
159static int ipw_set_geo(struct ieee80211_device *, const struct ieee80211_geo *);
160static const struct ieee80211_geo *ipw_get_geo(struct ieee80211_device *);
161
162static int snprint_line(char *buf, size_t count, 156static int snprint_line(char *buf, size_t count,
163 const u8 * data, u32 len, u32 ofs) 157 const u8 * data, u32 len, u32 ofs)
164{ 158{
@@ -1654,7 +1648,7 @@ static ssize_t store_speed_scan(struct device *d, struct device_attribute *attr,
1654 break; 1648 break;
1655 } 1649 }
1656 1650
1657 if (ipw_is_valid_channel(priv->ieee, channel)) 1651 if (ieee80211_is_valid_channel(priv->ieee, channel))
1658 priv->speed_scan[pos++] = channel; 1652 priv->speed_scan[pos++] = channel;
1659 else 1653 else
1660 IPW_WARNING("Skipping invalid channel request: %d\n", 1654 IPW_WARNING("Skipping invalid channel request: %d\n",
@@ -2222,7 +2216,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power)
2222 2216
2223static int ipw_set_tx_power(struct ipw_priv *priv) 2217static int ipw_set_tx_power(struct ipw_priv *priv)
2224{ 2218{
2225 const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee); 2219 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
2226 struct ipw_tx_power tx_power; 2220 struct ipw_tx_power tx_power;
2227 s8 max_power; 2221 s8 max_power;
2228 int i; 2222 int i;
@@ -5562,7 +5556,7 @@ static int ipw_best_network(struct ipw_priv *priv,
5562 } 5556 }
5563 5557
5564 /* Filter out invalid channel in current GEO */ 5558 /* Filter out invalid channel in current GEO */
5565 if (!ipw_is_valid_channel(priv->ieee, network->channel)) { 5559 if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) {
5566 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " 5560 IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
5567 "because of invalid channel in current GEO\n", 5561 "because of invalid channel in current GEO\n",
5568 escape_essid(network->ssid, network->ssid_len), 5562 escape_essid(network->ssid, network->ssid_len),
@@ -5607,7 +5601,7 @@ static int ipw_best_network(struct ipw_priv *priv,
5607static void ipw_adhoc_create(struct ipw_priv *priv, 5601static void ipw_adhoc_create(struct ipw_priv *priv,
5608 struct ieee80211_network *network) 5602 struct ieee80211_network *network)
5609{ 5603{
5610 const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee); 5604 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
5611 int i; 5605 int i;
5612 5606
5613 /* 5607 /*
@@ -5622,10 +5616,10 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
5622 * FW fatal error. 5616 * FW fatal error.
5623 * 5617 *
5624 */ 5618 */
5625 switch (ipw_is_valid_channel(priv->ieee, priv->channel)) { 5619 switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) {
5626 case IEEE80211_52GHZ_BAND: 5620 case IEEE80211_52GHZ_BAND:
5627 network->mode = IEEE_A; 5621 network->mode = IEEE_A;
5628 i = ipw_channel_to_index(priv->ieee, priv->channel); 5622 i = ieee80211_channel_to_index(priv->ieee, priv->channel);
5629 if (i == -1) 5623 if (i == -1)
5630 BUG(); 5624 BUG();
5631 if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) { 5625 if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
@@ -5639,7 +5633,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
5639 network->mode = IEEE_G; 5633 network->mode = IEEE_G;
5640 else 5634 else
5641 network->mode = IEEE_B; 5635 network->mode = IEEE_B;
5642 i = ipw_channel_to_index(priv->ieee, priv->channel); 5636 i = ieee80211_channel_to_index(priv->ieee, priv->channel);
5643 if (i == -1) 5637 if (i == -1)
5644 BUG(); 5638 BUG();
5645 if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) { 5639 if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
@@ -5963,7 +5957,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
5963 const struct ieee80211_geo *geo; 5957 const struct ieee80211_geo *geo;
5964 int i; 5958 int i;
5965 5959
5966 geo = ipw_get_geo(priv->ieee); 5960 geo = ieee80211_get_geo(priv->ieee);
5967 5961
5968 if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { 5962 if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) {
5969 int start = channel_index; 5963 int start = channel_index;
@@ -6023,7 +6017,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6023 channel_index++; 6017 channel_index++;
6024 scan->channels_list[channel_index] = channel; 6018 scan->channels_list[channel_index] = channel;
6025 index = 6019 index =
6026 ipw_channel_to_index(priv->ieee, channel); 6020 ieee80211_channel_to_index(priv->ieee, channel);
6027 ipw_set_scan_type(scan, channel_index, 6021 ipw_set_scan_type(scan, channel_index,
6028 geo->bg[index]. 6022 geo->bg[index].
6029 flags & 6023 flags &
@@ -6105,7 +6099,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
6105 u8 channel; 6099 u8 channel;
6106 u8 band = 0; 6100 u8 band = 0;
6107 6101
6108 switch (ipw_is_valid_channel(priv->ieee, priv->channel)) { 6102 switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) {
6109 case IEEE80211_52GHZ_BAND: 6103 case IEEE80211_52GHZ_BAND:
6110 band = (u8) (IPW_A_MODE << 6) | 1; 6104 band = (u8) (IPW_A_MODE << 6) | 1;
6111 channel = priv->channel; 6105 channel = priv->channel;
@@ -8200,7 +8194,7 @@ static int ipw_wx_set_freq(struct net_device *dev,
8200 union iwreq_data *wrqu, char *extra) 8194 union iwreq_data *wrqu, char *extra)
8201{ 8195{
8202 struct ipw_priv *priv = ieee80211_priv(dev); 8196 struct ipw_priv *priv = ieee80211_priv(dev);
8203 const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee); 8197 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
8204 struct iw_freq *fwrq = &wrqu->freq; 8198 struct iw_freq *fwrq = &wrqu->freq;
8205 int ret = 0, i; 8199 int ret = 0, i;
8206 u8 channel, flags; 8200 u8 channel, flags;
@@ -8215,17 +8209,17 @@ static int ipw_wx_set_freq(struct net_device *dev,
8215 } 8209 }
8216 /* if setting by freq convert to channel */ 8210 /* if setting by freq convert to channel */
8217 if (fwrq->e == 1) { 8211 if (fwrq->e == 1) {
8218 channel = ipw_freq_to_channel(priv->ieee, fwrq->m); 8212 channel = ieee80211_freq_to_channel(priv->ieee, fwrq->m);
8219 if (channel == 0) 8213 if (channel == 0)
8220 return -EINVAL; 8214 return -EINVAL;
8221 } else 8215 } else
8222 channel = fwrq->m; 8216 channel = fwrq->m;
8223 8217
8224 if (!(band = ipw_is_valid_channel(priv->ieee, channel))) 8218 if (!(band = ieee80211_is_valid_channel(priv->ieee, channel)))
8225 return -EINVAL; 8219 return -EINVAL;
8226 8220
8227 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 8221 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
8228 i = ipw_channel_to_index(priv->ieee, channel); 8222 i = ieee80211_channel_to_index(priv->ieee, channel);
8229 if (i == -1) 8223 if (i == -1)
8230 return -EINVAL; 8224 return -EINVAL;
8231 8225
@@ -8353,7 +8347,7 @@ static int ipw_wx_get_range(struct net_device *dev,
8353{ 8347{
8354 struct ipw_priv *priv = ieee80211_priv(dev); 8348 struct ipw_priv *priv = ieee80211_priv(dev);
8355 struct iw_range *range = (struct iw_range *)extra; 8349 struct iw_range *range = (struct iw_range *)extra;
8356 const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee); 8350 const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
8357 int i = 0, j; 8351 int i = 0, j;
8358 8352
8359 wrqu->data.length = sizeof(*range); 8353 wrqu->data.length = sizeof(*range);
@@ -10617,96 +10611,6 @@ static const struct ieee80211_geo ipw_geos[] = {
10617 } 10611 }
10618}; 10612};
10619 10613
10620/* GEO code borrowed from ieee80211_geo.c */
10621static int ipw_is_valid_channel(struct ieee80211_device *ieee, u8 channel)
10622{
10623 int i;
10624
10625 /* Driver needs to initialize the geography map before using
10626 * these helper functions */
10627 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
10628
10629 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
10630 for (i = 0; i < ieee->geo.bg_channels; i++)
10631 /* NOTE: If G mode is currently supported but
10632 * this is a B only channel, we don't see it
10633 * as valid. */
10634 if ((ieee->geo.bg[i].channel == channel) &&
10635 (!(ieee->mode & IEEE_G) ||
10636 !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY)))
10637 return IEEE80211_24GHZ_BAND;
10638
10639 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
10640 for (i = 0; i < ieee->geo.a_channels; i++)
10641 if (ieee->geo.a[i].channel == channel)
10642 return IEEE80211_52GHZ_BAND;
10643
10644 return 0;
10645}
10646
10647static int ipw_channel_to_index(struct ieee80211_device *ieee, u8 channel)
10648{
10649 int i;
10650
10651 /* Driver needs to initialize the geography map before using
10652 * these helper functions */
10653 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
10654
10655 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
10656 for (i = 0; i < ieee->geo.bg_channels; i++)
10657 if (ieee->geo.bg[i].channel == channel)
10658 return i;
10659
10660 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
10661 for (i = 0; i < ieee->geo.a_channels; i++)
10662 if (ieee->geo.a[i].channel == channel)
10663 return i;
10664
10665 return -1;
10666}
10667
10668static u8 ipw_freq_to_channel(struct ieee80211_device *ieee, u32 freq)
10669{
10670 int i;
10671
10672 /* Driver needs to initialize the geography map before using
10673 * these helper functions */
10674 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
10675
10676 freq /= 100000;
10677
10678 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
10679 for (i = 0; i < ieee->geo.bg_channels; i++)
10680 if (ieee->geo.bg[i].freq == freq)
10681 return ieee->geo.bg[i].channel;
10682
10683 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
10684 for (i = 0; i < ieee->geo.a_channels; i++)
10685 if (ieee->geo.a[i].freq == freq)
10686 return ieee->geo.a[i].channel;
10687
10688 return 0;
10689}
10690
10691static int ipw_set_geo(struct ieee80211_device *ieee,
10692 const struct ieee80211_geo *geo)
10693{
10694 memcpy(ieee->geo.name, geo->name, 3);
10695 ieee->geo.name[3] = '\0';
10696 ieee->geo.bg_channels = geo->bg_channels;
10697 ieee->geo.a_channels = geo->a_channels;
10698 memcpy(ieee->geo.bg, geo->bg, geo->bg_channels *
10699 sizeof(struct ieee80211_channel));
10700 memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels *
10701 sizeof(struct ieee80211_channel));
10702 return 0;
10703}
10704
10705static const struct ieee80211_geo *ipw_get_geo(struct ieee80211_device *ieee)
10706{
10707 return &ieee->geo;
10708}
10709
10710#define MAX_HW_RESTARTS 5 10614#define MAX_HW_RESTARTS 5
10711static int ipw_up(struct ipw_priv *priv) 10615static int ipw_up(struct ipw_priv *priv)
10712{ 10616{
@@ -10753,7 +10657,7 @@ static int ipw_up(struct ipw_priv *priv)
10753 priv->eeprom[EEPROM_COUNTRY_CODE + 2]); 10657 priv->eeprom[EEPROM_COUNTRY_CODE + 2]);
10754 j = 0; 10658 j = 0;
10755 } 10659 }
10756 if (ipw_set_geo(priv->ieee, &ipw_geos[j])) { 10660 if (ieee80211_set_geo(priv->ieee, &ipw_geos[j])) {
10757 IPW_WARNING("Could not set geography."); 10661 IPW_WARNING("Could not set geography.");
10758 return 0; 10662 return 0;
10759 } 10663 }