aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKolekar, Abhijeet <abhijeet.kolekar@intel.com>2008-12-18 21:37:40 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:59:21 -0500
commit90a30a021eec15da64a354656cb66987216361eb (patch)
treed5086677a3f2f6e88865f99dfb0bda9731c228d5 /drivers
parent854682ed2892836d7cff77931a79183c1fc59fef (diff)
iwl3945: simplify iwl3945_pci_probe
The patch simplifies iwl3945_pci_probe. It also uses apm_ops for apm init. Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c146
1 files changed, 79 insertions, 67 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 11660f67d6ab..b84509763ac7 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -7422,6 +7422,62 @@ static struct ieee80211_ops iwl3945_hw_ops = {
7422 .hw_scan = iwl3945_mac_hw_scan 7422 .hw_scan = iwl3945_mac_hw_scan
7423}; 7423};
7424 7424
7425int iwl3945_init_drv(struct iwl_priv *priv)
7426{
7427 int ret;
7428
7429 priv->retry_rate = 1;
7430 priv->ibss_beacon = NULL;
7431
7432 spin_lock_init(&priv->lock);
7433 spin_lock_init(&priv->power_data.lock);
7434 spin_lock_init(&priv->sta_lock);
7435 spin_lock_init(&priv->hcmd_lock);
7436
7437 INIT_LIST_HEAD(&priv->free_frames);
7438
7439 mutex_init(&priv->mutex);
7440
7441 /* Clear the driver's (not device's) station table */
7442 iwl3945_clear_stations_table(priv);
7443
7444 priv->data_retry_limit = -1;
7445 priv->ieee_channels = NULL;
7446 priv->ieee_rates = NULL;
7447 priv->band = IEEE80211_BAND_2GHZ;
7448
7449 priv->iw_mode = NL80211_IFTYPE_STATION;
7450
7451 iwl_reset_qos(priv);
7452
7453 priv->qos_data.qos_active = 0;
7454 priv->qos_data.qos_cap.val = 0;
7455
7456 priv->rates_mask = IWL_RATES_MASK;
7457 /* If power management is turned on, default to AC mode */
7458 priv->power_mode = IWL_POWER_AC;
7459 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
7460
7461 ret = iwl3945_init_channel_map(priv);
7462 if (ret) {
7463 IWL_ERR(priv, "initializing regulatory failed: %d\n", ret);
7464 goto err;
7465 }
7466
7467 ret = iwl3945_init_geos(priv);
7468 if (ret) {
7469 IWL_ERR(priv, "initializing geos failed: %d\n", ret);
7470 goto err_free_channel_map;
7471 }
7472
7473 return 0;
7474
7475err_free_channel_map:
7476 iwl3945_free_channel_map(priv);
7477err:
7478 return ret;
7479}
7480
7425static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 7481static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7426{ 7482{
7427 int err = 0; 7483 int err = 0;
@@ -7436,19 +7492,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7436 7492
7437 /* mac80211 allocates memory for this device instance, including 7493 /* mac80211 allocates memory for this device instance, including
7438 * space for this driver's private structure */ 7494 * space for this driver's private structure */
7439 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwl3945_hw_ops); 7495 hw = iwl_alloc_all(cfg, &iwl3945_hw_ops);
7440 if (hw == NULL) { 7496 if (hw == NULL) {
7441 printk(KERN_ERR DRV_NAME "Can not allocate network device\n"); 7497 printk(KERN_ERR DRV_NAME "Can not allocate network device\n");
7442 err = -ENOMEM; 7498 err = -ENOMEM;
7443 goto out; 7499 goto out;
7444 } 7500 }
7445
7446 SET_IEEE80211_DEV(hw, &pdev->dev);
7447
7448 priv = hw->priv; 7501 priv = hw->priv;
7449 priv->hw = hw; 7502 SET_IEEE80211_DEV(hw, &pdev->dev);
7450 priv->pci_dev = pdev;
7451 priv->cfg = cfg;
7452 7503
7453 if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) || 7504 if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) ||
7454 (iwl3945_mod_params.num_of_queues < IWL_MIN_NUM_QUEUES)) { 7505 (iwl3945_mod_params.num_of_queues < IWL_MIN_NUM_QUEUES)) {
@@ -7459,23 +7510,29 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7459 goto out; 7510 goto out;
7460 } 7511 }
7461 7512
7462 /* Disabling hardware scan means that mac80211 will perform scans 7513 /*
7463 * "the hard way", rather than using device's scan. */ 7514 * Disabling hardware scan means that mac80211 will perform scans
7515 * "the hard way", rather than using device's scan.
7516 */
7464 if (iwl3945_mod_params.disable_hw_scan) { 7517 if (iwl3945_mod_params.disable_hw_scan) {
7465 IWL_DEBUG_INFO("Disabling hw_scan\n"); 7518 IWL_DEBUG_INFO("Disabling hw_scan\n");
7466 iwl3945_hw_ops.hw_scan = NULL; 7519 iwl3945_hw_ops.hw_scan = NULL;
7467 } 7520 }
7468 7521
7522
7469 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 7523 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
7470 hw->rate_control_algorithm = "iwl-3945-rs"; 7524 priv->cfg = cfg;
7471 hw->sta_data_size = sizeof(struct iwl3945_sta_priv); 7525 priv->pci_dev = pdev;
7472 7526
7473 /* Select antenna (may be helpful if only one antenna is connected) */
7474 priv->antenna = (enum iwl3945_antenna)iwl3945_mod_params.antenna;
7475#ifdef CONFIG_IWL3945_DEBUG 7527#ifdef CONFIG_IWL3945_DEBUG
7476 priv->debug_level = iwl3945_mod_params.debug; 7528 priv->debug_level = iwl3945_mod_params.debug;
7477 atomic_set(&priv->restrict_refcnt, 0); 7529 atomic_set(&priv->restrict_refcnt, 0);
7478#endif 7530#endif
7531 hw->rate_control_algorithm = "iwl-3945-rs";
7532 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
7533
7534 /* Select antenna (may be helpful if only one antenna is connected) */
7535 priv->antenna = (enum iwl3945_antenna)iwl3945_mod_params.antenna;
7479 7536
7480 /* Tell mac80211 our characteristics */ 7537 /* Tell mac80211 our characteristics */
7481 hw->flags = IEEE80211_HW_SIGNAL_DBM | 7538 hw->flags = IEEE80211_HW_SIGNAL_DBM |
@@ -7530,21 +7587,17 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7530 * PCI Tx retries from interfering with C3 CPU state */ 7587 * PCI Tx retries from interfering with C3 CPU state */
7531 pci_write_config_byte(pdev, 0x41, 0x00); 7588 pci_write_config_byte(pdev, 0x41, 0x00);
7532 7589
7533 /* nic init */ 7590 /* amp init */
7534 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, 7591 err = priv->cfg->ops->lib->apm_ops.init(priv);
7535 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
7536
7537 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
7538 err = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
7539 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
7540 if (err < 0) { 7592 if (err < 0) {
7541 IWL_DEBUG_INFO("Failed to init the APMG\n"); 7593 IWL_DEBUG_INFO("Failed to init APMG\n");
7542 goto out_remove_sysfs; 7594 goto out_iounmap;
7543 } 7595 }
7544 7596
7545 /*********************** 7597 /***********************
7546 * 4. Read EEPROM 7598 * 4. Read EEPROM
7547 * ********************/ 7599 * ********************/
7600
7548 /* Read the EEPROM */ 7601 /* Read the EEPROM */
7549 err = iwl3945_eeprom_init(priv); 7602 err = iwl3945_eeprom_init(priv);
7550 if (err) { 7603 if (err) {
@@ -7568,48 +7621,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7568 /*********************** 7621 /***********************
7569 * 6. Setup priv 7622 * 6. Setup priv
7570 * ********************/ 7623 * ********************/
7571 priv->retry_rate = 1;
7572 priv->ibss_beacon = NULL;
7573
7574 spin_lock_init(&priv->lock);
7575 spin_lock_init(&priv->power_data_39.lock);
7576 spin_lock_init(&priv->sta_lock);
7577 spin_lock_init(&priv->hcmd_lock);
7578
7579 INIT_LIST_HEAD(&priv->free_frames);
7580 mutex_init(&priv->mutex);
7581
7582 /* Clear the driver's (not device's) station table */
7583 iwl3945_clear_stations_table(priv);
7584 7624
7585 priv->data_retry_limit = -1; 7625 err = iwl3945_init_drv(priv);
7586 priv->ieee_channels = NULL;
7587 priv->ieee_rates = NULL;
7588 priv->band = IEEE80211_BAND_2GHZ;
7589
7590 priv->iw_mode = NL80211_IFTYPE_STATION;
7591
7592 iwl_reset_qos(priv);
7593
7594 priv->qos_data.qos_active = 0;
7595 priv->qos_data.qos_cap.val = 0;
7596
7597
7598 priv->rates_mask = IWL_RATES_MASK;
7599 /* If power management is turned on, default to AC mode */
7600 priv->power_mode = IWL39_POWER_AC;
7601 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
7602
7603 err = iwl3945_init_channel_map(priv);
7604 if (err) {
7605 IWL_ERR(priv, "initializing regulatory failed: %d\n", err);
7606 goto out_release_irq;
7607 }
7608
7609 err = iwl3945_init_geos(priv);
7610 if (err) { 7626 if (err) {
7611 IWL_ERR(priv, "initializing geos failed: %d\n", err); 7627 IWL_ERR(priv, "initializing driver failed\n");
7612 goto out_free_channel_map; 7628 goto out_free_geos;
7613 } 7629 }
7614 7630
7615 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", 7631 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n",
@@ -7638,7 +7654,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7638 err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); 7654 err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7639 if (err) { 7655 if (err) {
7640 IWL_ERR(priv, "failed to create sysfs device attributes\n"); 7656 IWL_ERR(priv, "failed to create sysfs device attributes\n");
7641 goto out_free_geos; 7657 goto out_release_irq;
7642 } 7658 }
7643 7659
7644 iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 7660 iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
@@ -7664,7 +7680,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7664 priv->hw->conf.beacon_int = 100; 7680 priv->hw->conf.beacon_int = 100;
7665 priv->mac80211_registered = 1; 7681 priv->mac80211_registered = 1;
7666 7682
7667
7668 err = iwl3945_rfkill_init(priv); 7683 err = iwl3945_rfkill_init(priv);
7669 if (err) 7684 if (err)
7670 IWL_ERR(priv, "Unable to initialize RFKILL system. " 7685 IWL_ERR(priv, "Unable to initialize RFKILL system. "
@@ -7676,9 +7691,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7676 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 7691 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7677 out_free_geos: 7692 out_free_geos:
7678 iwl3945_free_geos(priv); 7693 iwl3945_free_geos(priv);
7679 out_free_channel_map:
7680 iwl3945_free_channel_map(priv);
7681
7682 7694
7683 out_release_irq: 7695 out_release_irq:
7684 destroy_workqueue(priv->workqueue); 7696 destroy_workqueue(priv->workqueue);