diff options
author | Samuel Ortiz <samuel.ortiz@intel.com> | 2009-01-23 16:45:16 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:35 -0500 |
commit | 534166dedaa9a660c7221b145b5e4088a2d9ac69 (patch) | |
tree | f747a444b895ed9807dbd581e93c2ae151a23e24 /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | e6148917db2c223fa7edd3dfb64d99756a86b452 (diff) |
iwl3945: Use the iwlcore geos routines
By removing the init_rates() routine outside of the init_geos() one, we can
share the geos routines between 3945 and agn.
Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@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 | 145 |
1 files changed, 11 insertions, 134 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index b57c2b8c8dcf..5fa5cb2c21a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -3383,137 +3383,6 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv, | |||
3383 | } | 3383 | } |
3384 | } | 3384 | } |
3385 | 3385 | ||
3386 | /** | ||
3387 | * iwl3945_init_geos - Initialize mac80211's geo/channel info based from eeprom | ||
3388 | */ | ||
3389 | #define IEEE80211_24GHZ_MAX_CHANNEL 14 | ||
3390 | static int iwl3945_init_geos(struct iwl_priv *priv) | ||
3391 | { | ||
3392 | struct iwl_channel_info *ch; | ||
3393 | struct ieee80211_supported_band *sband; | ||
3394 | struct ieee80211_channel *channels; | ||
3395 | struct ieee80211_channel *geo_ch; | ||
3396 | struct ieee80211_rate *rates; | ||
3397 | int i = 0; | ||
3398 | |||
3399 | if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || | ||
3400 | priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { | ||
3401 | IWL_DEBUG_INFO("Geography modes already initialized.\n"); | ||
3402 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | ||
3403 | return 0; | ||
3404 | } | ||
3405 | |||
3406 | channels = kzalloc(sizeof(struct ieee80211_channel) * | ||
3407 | priv->channel_count, GFP_KERNEL); | ||
3408 | if (!channels) | ||
3409 | return -ENOMEM; | ||
3410 | |||
3411 | rates = kzalloc((sizeof(struct ieee80211_rate) * (IWL_RATE_COUNT + 1)), | ||
3412 | GFP_KERNEL); | ||
3413 | if (!rates) { | ||
3414 | kfree(channels); | ||
3415 | return -ENOMEM; | ||
3416 | } | ||
3417 | |||
3418 | /* 5.2GHz channels start after the 2.4GHz channels */ | ||
3419 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; | ||
3420 | sband->channels = &channels[IEEE80211_24GHZ_MAX_CHANNEL]; | ||
3421 | /* just OFDM */ | ||
3422 | sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; | ||
3423 | sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; | ||
3424 | |||
3425 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; | ||
3426 | sband->channels = channels; | ||
3427 | /* OFDM & CCK */ | ||
3428 | sband->bitrates = rates; | ||
3429 | sband->n_bitrates = IWL_RATE_COUNT; | ||
3430 | |||
3431 | priv->ieee_channels = channels; | ||
3432 | priv->ieee_rates = rates; | ||
3433 | |||
3434 | iwl3945_init_hw_rates(priv, rates); | ||
3435 | |||
3436 | for (i = 0; i < priv->channel_count; i++) { | ||
3437 | ch = &priv->channel_info[i]; | ||
3438 | |||
3439 | /* FIXME: might be removed if scan is OK*/ | ||
3440 | if (!is_channel_valid(ch)) | ||
3441 | continue; | ||
3442 | |||
3443 | if (is_channel_a_band(ch)) | ||
3444 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; | ||
3445 | else | ||
3446 | sband = &priv->bands[IEEE80211_BAND_2GHZ]; | ||
3447 | |||
3448 | geo_ch = &sband->channels[sband->n_channels++]; | ||
3449 | |||
3450 | geo_ch->center_freq = ieee80211_channel_to_frequency(ch->channel); | ||
3451 | geo_ch->max_power = ch->max_power_avg; | ||
3452 | geo_ch->max_antenna_gain = 0xff; | ||
3453 | geo_ch->hw_value = ch->channel; | ||
3454 | |||
3455 | if (is_channel_valid(ch)) { | ||
3456 | if (!(ch->flags & EEPROM_CHANNEL_IBSS)) | ||
3457 | geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; | ||
3458 | |||
3459 | if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) | ||
3460 | geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; | ||
3461 | |||
3462 | if (ch->flags & EEPROM_CHANNEL_RADAR) | ||
3463 | geo_ch->flags |= IEEE80211_CHAN_RADAR; | ||
3464 | |||
3465 | if (ch->max_power_avg > priv->tx_power_channel_lmt) | ||
3466 | priv->tx_power_channel_lmt = | ||
3467 | ch->max_power_avg; | ||
3468 | } else { | ||
3469 | geo_ch->flags |= IEEE80211_CHAN_DISABLED; | ||
3470 | } | ||
3471 | |||
3472 | /* Save flags for reg domain usage */ | ||
3473 | geo_ch->orig_flags = geo_ch->flags; | ||
3474 | |||
3475 | IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0%X\n", | ||
3476 | ch->channel, geo_ch->center_freq, | ||
3477 | is_channel_a_band(ch) ? "5.2" : "2.4", | ||
3478 | geo_ch->flags & IEEE80211_CHAN_DISABLED ? | ||
3479 | "restricted" : "valid", | ||
3480 | geo_ch->flags); | ||
3481 | } | ||
3482 | |||
3483 | if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && | ||
3484 | priv->cfg->sku & IWL_SKU_A) { | ||
3485 | IWL_INFO(priv, "Incorrectly detected BG card as ABG. " | ||
3486 | "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", | ||
3487 | priv->pci_dev->device, priv->pci_dev->subsystem_device); | ||
3488 | priv->cfg->sku &= ~IWL_SKU_A; | ||
3489 | } | ||
3490 | |||
3491 | IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", | ||
3492 | priv->bands[IEEE80211_BAND_2GHZ].n_channels, | ||
3493 | priv->bands[IEEE80211_BAND_5GHZ].n_channels); | ||
3494 | |||
3495 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
3496 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
3497 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
3498 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
3499 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
3500 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
3501 | |||
3502 | set_bit(STATUS_GEO_CONFIGURED, &priv->status); | ||
3503 | |||
3504 | return 0; | ||
3505 | } | ||
3506 | |||
3507 | /* | ||
3508 | * iwl3945_free_geos - undo allocations in iwl3945_init_geos | ||
3509 | */ | ||
3510 | static void iwl3945_free_geos(struct iwl_priv *priv) | ||
3511 | { | ||
3512 | kfree(priv->ieee_channels); | ||
3513 | kfree(priv->ieee_rates); | ||
3514 | clear_bit(STATUS_GEO_CONFIGURED, &priv->status); | ||
3515 | } | ||
3516 | |||
3517 | /****************************************************************************** | 3386 | /****************************************************************************** |
3518 | * | 3387 | * |
3519 | * uCode download functions | 3388 | * uCode download functions |
@@ -6144,11 +6013,19 @@ static int iwl3945_init_drv(struct iwl_priv *priv) | |||
6144 | goto err_free_channel_map; | 6013 | goto err_free_channel_map; |
6145 | } | 6014 | } |
6146 | 6015 | ||
6147 | ret = iwl3945_init_geos(priv); | 6016 | ret = iwlcore_init_geos(priv); |
6148 | if (ret) { | 6017 | if (ret) { |
6149 | IWL_ERR(priv, "initializing geos failed: %d\n", ret); | 6018 | IWL_ERR(priv, "initializing geos failed: %d\n", ret); |
6150 | goto err_free_channel_map; | 6019 | goto err_free_channel_map; |
6151 | } | 6020 | } |
6021 | iwl3945_init_hw_rates(priv, priv->ieee_rates); | ||
6022 | |||
6023 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) | ||
6024 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | ||
6025 | &priv->bands[IEEE80211_BAND_2GHZ]; | ||
6026 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) | ||
6027 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | ||
6028 | &priv->bands[IEEE80211_BAND_5GHZ]; | ||
6152 | 6029 | ||
6153 | return 0; | 6030 | return 0; |
6154 | 6031 | ||
@@ -6379,7 +6256,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6379 | out_remove_sysfs: | 6256 | out_remove_sysfs: |
6380 | sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); | 6257 | sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); |
6381 | out_free_geos: | 6258 | out_free_geos: |
6382 | iwl3945_free_geos(priv); | 6259 | iwlcore_free_geos(priv); |
6383 | 6260 | ||
6384 | out_release_irq: | 6261 | out_release_irq: |
6385 | free_irq(priv->pci_dev->irq, priv); | 6262 | free_irq(priv->pci_dev->irq, priv); |
@@ -6461,7 +6338,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) | |||
6461 | pci_set_drvdata(pdev, NULL); | 6338 | pci_set_drvdata(pdev, NULL); |
6462 | 6339 | ||
6463 | iwl_free_channel_map(priv); | 6340 | iwl_free_channel_map(priv); |
6464 | iwl3945_free_geos(priv); | 6341 | iwlcore_free_geos(priv); |
6465 | kfree(priv->scan); | 6342 | kfree(priv->scan); |
6466 | if (priv->ibss_beacon) | 6343 | if (priv->ibss_beacon) |
6467 | dev_kfree_skb(priv->ibss_beacon); | 6344 | dev_kfree_skb(priv->ibss_beacon); |