diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-03-01 18:36:04 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-03-06 17:09:45 -0500 |
commit | 8211ef78d9023a8772e5acf6b7934598156b2fc8 (patch) | |
tree | 2306bb8216c131adaea6b36f09ff35db9975193d /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | 2acae16ee79386c73db10fa8e95c9cd42fbad272 (diff) |
iwlwifi: refactor init geos function
This patch refactors init geos function. It also fixes few minor bugs.
IWL_MAX_RATE -> IWL_RATE_COUNT (IWL_MAX_RATE included also MCS setting)
There are 9 and 13 rates for 4965 in 2.4 and 5.2 respectively (rate 60)
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 139a4a24bc00..0cafbd42d84c 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -5118,11 +5118,12 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv) | |||
5118 | ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; | 5118 | ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; |
5119 | ch_info->min_power = 0; | 5119 | ch_info->min_power = 0; |
5120 | 5120 | ||
5121 | IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x" | 5121 | IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s%s(0x%02x" |
5122 | " %ddBm): Ad-Hoc %ssupported\n", | 5122 | " %ddBm): Ad-Hoc %ssupported\n", |
5123 | ch_info->channel, | 5123 | ch_info->channel, |
5124 | is_channel_a_band(ch_info) ? | 5124 | is_channel_a_band(ch_info) ? |
5125 | "5.2" : "2.4", | 5125 | "5.2" : "2.4", |
5126 | CHECK_AND_PRINT(VALID), | ||
5126 | CHECK_AND_PRINT(IBSS), | 5127 | CHECK_AND_PRINT(IBSS), |
5127 | CHECK_AND_PRINT(ACTIVE), | 5128 | CHECK_AND_PRINT(ACTIVE), |
5128 | CHECK_AND_PRINT(RADAR), | 5129 | CHECK_AND_PRINT(RADAR), |
@@ -5332,7 +5333,7 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv, | |||
5332 | static int iwl3945_init_geos(struct iwl3945_priv *priv) | 5333 | static int iwl3945_init_geos(struct iwl3945_priv *priv) |
5333 | { | 5334 | { |
5334 | struct iwl3945_channel_info *ch; | 5335 | struct iwl3945_channel_info *ch; |
5335 | struct ieee80211_supported_band *band; | 5336 | struct ieee80211_supported_band *sband; |
5336 | struct ieee80211_channel *channels; | 5337 | struct ieee80211_channel *channels; |
5337 | struct ieee80211_channel *geo_ch; | 5338 | struct ieee80211_channel *geo_ch; |
5338 | struct ieee80211_rate *rates; | 5339 | struct ieee80211_rate *rates; |
@@ -5350,7 +5351,7 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5350 | if (!channels) | 5351 | if (!channels) |
5351 | return -ENOMEM; | 5352 | return -ENOMEM; |
5352 | 5353 | ||
5353 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_MAX_RATES + 1)), | 5354 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_RATE_COUNT + 1)), |
5354 | GFP_KERNEL); | 5355 | GFP_KERNEL); |
5355 | if (!rates) { | 5356 | if (!rates) { |
5356 | kfree(channels); | 5357 | kfree(channels); |
@@ -5358,38 +5359,38 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5358 | } | 5359 | } |
5359 | 5360 | ||
5360 | /* 5.2GHz channels start after the 2.4GHz channels */ | 5361 | /* 5.2GHz channels start after the 2.4GHz channels */ |
5361 | band = &priv->bands[IEEE80211_BAND_5GHZ]; | 5362 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; |
5362 | band->channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; | 5363 | sband->channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; |
5363 | band->bitrates = &rates[4]; | 5364 | /* just OFDM */ |
5364 | band->n_bitrates = 8; /* just OFDM */ | 5365 | sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; |
5365 | 5366 | sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; | |
5366 | band = &priv->bands[IEEE80211_BAND_2GHZ]; | 5367 | |
5367 | band->channels = channels; | 5368 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; |
5368 | band->bitrates = rates; | 5369 | sband->channels = channels; |
5369 | band->n_bitrates = 12; /* OFDM & CCK */ | 5370 | /* OFDM & CCK */ |
5371 | sband->bitrates = rates; | ||
5372 | sband->n_bitrates = IWL_RATE_COUNT; | ||
5370 | 5373 | ||
5371 | priv->ieee_channels = channels; | 5374 | priv->ieee_channels = channels; |
5372 | priv->ieee_rates = rates; | 5375 | priv->ieee_rates = rates; |
5373 | 5376 | ||
5374 | iwl3945_init_hw_rates(priv, rates); | 5377 | iwl3945_init_hw_rates(priv, rates); |
5375 | 5378 | ||
5376 | for (i = 0, geo_ch = channels; i < priv->channel_count; i++) { | 5379 | for (i = 0; i < priv->channel_count; i++) { |
5377 | ch = &priv->channel_info[i]; | 5380 | ch = &priv->channel_info[i]; |
5378 | 5381 | ||
5379 | if (!is_channel_valid(ch)) { | 5382 | /* FIXME: might be removed if scan is OK*/ |
5380 | IWL_DEBUG_INFO("Channel %d [%sGHz] is restricted -- " | 5383 | if (!is_channel_valid(ch)) |
5381 | "skipping.\n", | ||
5382 | ch->channel, is_channel_a_band(ch) ? | ||
5383 | "5.2" : "2.4"); | ||
5384 | continue; | 5384 | continue; |
5385 | } | ||
5386 | 5385 | ||
5387 | if (is_channel_a_band(ch)) | 5386 | if (is_channel_a_band(ch)) |
5388 | geo_ch = &priv->bands[IEEE80211_BAND_5GHZ].channels[priv->bands[IEEE80211_BAND_5GHZ].n_channels++]; | 5387 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; |
5389 | else | 5388 | else |
5390 | geo_ch = &priv->bands[IEEE80211_BAND_2GHZ].channels[priv->bands[IEEE80211_BAND_2GHZ].n_channels++]; | 5389 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; |
5391 | 5390 | ||
5392 | geo_ch->center_freq = ieee80211chan2mhz(ch->channel); | 5391 | geo_ch = &sband->channels[sband->n_channels++]; |
5392 | |||
5393 | geo_ch->center_freq = ieee80211_channel_to_frequency(ch->channel); | ||
5393 | geo_ch->max_power = ch->max_power_avg; | 5394 | geo_ch->max_power = ch->max_power_avg; |
5394 | geo_ch->max_antenna_gain = 0xff; | 5395 | geo_ch->max_antenna_gain = 0xff; |
5395 | geo_ch->hw_value = ch->channel; | 5396 | geo_ch->hw_value = ch->channel; |
@@ -5407,8 +5408,19 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv) | |||
5407 | if (ch->max_power_avg > priv->max_channel_txpower_limit) | 5408 | if (ch->max_power_avg > priv->max_channel_txpower_limit) |
5408 | priv->max_channel_txpower_limit = | 5409 | priv->max_channel_txpower_limit = |
5409 | ch->max_power_avg; | 5410 | ch->max_power_avg; |
5410 | } else | 5411 | } else { |
5411 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; | 5412 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; |
5413 | } | ||
5414 | |||
5415 | /* Save flags for reg domain usage */ | ||
5416 | geo_ch->orig_flags = geo_ch->flags; | ||
5417 | |||
5418 | IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0%X\n", | ||
5419 | ch->channel, geo_ch->center_freq, | ||
5420 | is_channel_a_band(ch) ? "5.2" : "2.4", | ||
5421 | geo_ch->flags & IEEE80211_CHAN_DISABLED ? | ||
5422 | "restricted" : "valid", | ||
5423 | geo_ch->flags); | ||
5412 | } | 5424 | } |
5413 | 5425 | ||
5414 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { | 5426 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && priv->is_abg) { |