aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAssaf Krauss <assaf.krauss@intel.com>2008-03-14 13:38:46 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-03-25 16:41:50 -0400
commit316c30d9dddc1bd5b586a6cf9808018746372cc9 (patch)
tree6b999e48dea5ca7d9143bbb4a1a3ec6e2260a94d /drivers
parent99f7d39bb020a06c98cd42641b6193b761f763ca (diff)
iwlwifi: Re-ordering probe flow (4965)
This patch re-orders the iwl4965_pci_probe function. Signed-off-by: Assaf Krauss <assaf.krauss@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c252
2 files changed, 151 insertions, 120 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index b2ea4d4f3f31..3d30cba0ad45 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1843,14 +1843,26 @@ int iwl4965_alive_notify(struct iwl_priv *priv)
1843 */ 1843 */
1844int iwl4965_hw_set_hw_setting(struct iwl_priv *priv) 1844int iwl4965_hw_set_hw_setting(struct iwl_priv *priv)
1845{ 1845{
1846 int ret = 0;
1847
1848 if ((iwl4965_param_queues_num > IWL_MAX_NUM_QUEUES) ||
1849 (iwl4965_param_queues_num < IWL_MIN_NUM_QUEUES)) {
1850 IWL_ERROR("invalid queues_num, should be between %d and %d\n",
1851 IWL_MIN_NUM_QUEUES, IWL_MAX_NUM_QUEUES);
1852 ret = -EINVAL;
1853 goto out;
1854 }
1855
1846 /* Allocate area for Tx byte count tables and Rx queue status */ 1856 /* Allocate area for Tx byte count tables and Rx queue status */
1847 priv->hw_setting.shared_virt = 1857 priv->hw_setting.shared_virt =
1848 pci_alloc_consistent(priv->pci_dev, 1858 pci_alloc_consistent(priv->pci_dev,
1849 sizeof(struct iwl4965_shared), 1859 sizeof(struct iwl4965_shared),
1850 &priv->hw_setting.shared_phys); 1860 &priv->hw_setting.shared_phys);
1851 1861
1852 if (!priv->hw_setting.shared_virt) 1862 if (!priv->hw_setting.shared_virt) {
1853 return -1; 1863 ret = -ENOMEM;
1864 goto out;
1865 }
1854 1866
1855 memset(priv->hw_setting.shared_virt, 0, sizeof(struct iwl4965_shared)); 1867 memset(priv->hw_setting.shared_virt, 0, sizeof(struct iwl4965_shared));
1856 1868
@@ -1868,7 +1880,8 @@ int iwl4965_hw_set_hw_setting(struct iwl_priv *priv)
1868 1880
1869 priv->hw_setting.tx_ant_num = 2; 1881 priv->hw_setting.tx_ant_num = 2;
1870 1882
1871 return 0; 1883out:
1884 return ret;
1872} 1885}
1873 1886
1874/** 1887/**
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 396940e701e5..a2ee34e40b20 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -8522,6 +8522,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8522 int i; 8522 int i;
8523 DECLARE_MAC_BUF(mac); 8523 DECLARE_MAC_BUF(mac);
8524 8524
8525 /************************
8526 * 1. Allocating HW data
8527 ************************/
8528
8525 /* Disabling hardware scan means that mac80211 will perform scans 8529 /* Disabling hardware scan means that mac80211 will perform scans
8526 * "the hard way", rather than using device's scan. */ 8530 * "the hard way", rather than using device's scan. */
8527 if (iwl4965_param_disable_hw_scan) { 8531 if (iwl4965_param_disable_hw_scan) {
@@ -8529,14 +8533,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8529 iwl4965_hw_ops.hw_scan = NULL; 8533 iwl4965_hw_ops.hw_scan = NULL;
8530 } 8534 }
8531 8535
8532 if ((iwl4965_param_queues_num > IWL_MAX_NUM_QUEUES) ||
8533 (iwl4965_param_queues_num < IWL_MIN_NUM_QUEUES)) {
8534 IWL_ERROR("invalid queues_num, should be between %d and %d\n",
8535 IWL_MIN_NUM_QUEUES, IWL_MAX_NUM_QUEUES);
8536 err = -EINVAL;
8537 goto out;
8538 }
8539
8540 /* mac80211 allocates memory for this device instance, including 8536 /* mac80211 allocates memory for this device instance, including
8541 * space for this driver's private structure */ 8537 * space for this driver's private structure */
8542 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwl4965_hw_ops); 8538 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwl4965_hw_ops);
@@ -8547,22 +8543,101 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8547 } 8543 }
8548 SET_IEEE80211_DEV(hw, &pdev->dev); 8544 SET_IEEE80211_DEV(hw, &pdev->dev);
8549 8545
8550 hw->rate_control_algorithm = "iwl-4965-rs";
8551
8552 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8546 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8553 priv = hw->priv; 8547 priv = hw->priv;
8554 priv->hw = hw; 8548 priv->hw = hw;
8555 priv->cfg = cfg; 8549 priv->cfg = cfg;
8556 8550
8557 priv->pci_dev = pdev; 8551 priv->pci_dev = pdev;
8558 priv->antenna = (enum iwl4965_antenna)iwl4965_param_antenna; 8552
8559#ifdef CONFIG_IWLWIFI_DEBUG 8553#ifdef CONFIG_IWLWIFI_DEBUG
8560 iwl_debug_level = iwl4965_param_debug; 8554 iwl_debug_level = iwl4965_param_debug;
8561 atomic_set(&priv->restrict_refcnt, 0); 8555 atomic_set(&priv->restrict_refcnt, 0);
8562#endif 8556#endif
8563 priv->retry_rate = 1;
8564 8557
8565 priv->ibss_beacon = NULL; 8558 /**************************
8559 * 2. Initializing PCI bus
8560 **************************/
8561 if (pci_enable_device(pdev)) {
8562 err = -ENODEV;
8563 goto out_ieee80211_free_hw;
8564 }
8565
8566 pci_set_master(pdev);
8567
8568 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
8569 if (!err)
8570 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
8571 if (err) {
8572 printk(KERN_WARNING DRV_NAME
8573 ": No suitable DMA available.\n");
8574 goto out_pci_disable_device;
8575 }
8576
8577 err = pci_request_regions(pdev, DRV_NAME);
8578 if (err)
8579 goto out_pci_disable_device;
8580
8581 pci_set_drvdata(pdev, priv);
8582
8583 /* We disable the RETRY_TIMEOUT register (0x41) to keep
8584 * PCI Tx retries from interfering with C3 CPU state */
8585 pci_write_config_byte(pdev, 0x41, 0x00);
8586
8587 /***********************
8588 * 3. Read REV register
8589 ***********************/
8590 priv->hw_base = pci_iomap(pdev, 0, 0);
8591 if (!priv->hw_base) {
8592 err = -ENODEV;
8593 goto out_pci_release_regions;
8594 }
8595
8596 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n",
8597 (unsigned long long) pci_resource_len(pdev, 0));
8598 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base);
8599
8600 printk(KERN_INFO DRV_NAME
8601 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
8602
8603 /*****************
8604 * 4. Read EEPROM
8605 *****************/
8606 /* nic init */
8607 iwl4965_set_bit(priv, CSR_GIO_CHICKEN_BITS,
8608 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
8609
8610 iwl4965_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
8611 err = iwl4965_poll_bit(priv, CSR_GP_CNTRL,
8612 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
8613 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
8614 if (err < 0) {
8615 IWL_DEBUG_INFO("Failed to init the card\n");
8616 goto out_iounmap;
8617 }
8618 /* Read the EEPROM */
8619 err = iwl_eeprom_init(priv);
8620 if (err) {
8621 IWL_ERROR("Unable to init EEPROM\n");
8622 goto out_iounmap;
8623 }
8624 /* MAC Address location in EEPROM same for 3945/4965 */
8625 iwl_eeprom_get_mac(priv, priv->mac_addr);
8626 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
8627 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8628
8629 /************************
8630 * 5. Setup HW constants
8631 ************************/
8632 /* Device-specific setup */
8633 if (iwl4965_hw_set_hw_setting(priv)) {
8634 IWL_ERROR("failed to set hw settings\n");
8635 goto out_iounmap;
8636 }
8637
8638 /*******************
8639 * 6. Setup hw/priv
8640 *******************/
8566 8641
8567 /* Tell mac80211 and its clients (e.g. Wireless Extensions) 8642 /* Tell mac80211 and its clients (e.g. Wireless Extensions)
8568 * the range of signal quality values that we'll provide. 8643 * the range of signal quality values that we'll provide.
@@ -8583,6 +8658,11 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8583 hw->queues = 16; 8658 hw->queues = 16;
8584#endif /* CONFIG_IWL4965_HT */ 8659#endif /* CONFIG_IWL4965_HT */
8585 8660
8661 hw->rate_control_algorithm = "iwl-4965-rs";
8662 priv->antenna = (enum iwl4965_antenna)iwl4965_param_antenna;
8663 priv->retry_rate = 1;
8664 priv->ibss_beacon = NULL;
8665
8586 spin_lock_init(&priv->lock); 8666 spin_lock_init(&priv->lock);
8587 spin_lock_init(&priv->power_data.lock); 8667 spin_lock_init(&priv->power_data.lock);
8588 spin_lock_init(&priv->sta_lock); 8668 spin_lock_init(&priv->sta_lock);
@@ -8595,12 +8675,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8595 INIT_LIST_HEAD(&priv->free_frames); 8675 INIT_LIST_HEAD(&priv->free_frames);
8596 8676
8597 mutex_init(&priv->mutex); 8677 mutex_init(&priv->mutex);
8598 if (pci_enable_device(pdev)) {
8599 err = -ENODEV;
8600 goto out_ieee80211_free_hw;
8601 }
8602
8603 pci_set_master(pdev);
8604 8678
8605 /* Clear the driver's (not device's) station table */ 8679 /* Clear the driver's (not device's) station table */
8606 iwl4965_clear_stations_table(priv); 8680 iwl4965_clear_stations_table(priv);
@@ -8610,44 +8684,8 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8610 priv->ieee_rates = NULL; 8684 priv->ieee_rates = NULL;
8611 priv->band = IEEE80211_BAND_2GHZ; 8685 priv->band = IEEE80211_BAND_2GHZ;
8612 8686
8613 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
8614 if (!err)
8615 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
8616 if (err) {
8617 printk(KERN_WARNING DRV_NAME ": No suitable DMA available.\n");
8618 goto out_pci_disable_device;
8619 }
8620
8621 pci_set_drvdata(pdev, priv);
8622 err = pci_request_regions(pdev, DRV_NAME);
8623 if (err)
8624 goto out_pci_disable_device;
8625
8626 /* We disable the RETRY_TIMEOUT register (0x41) to keep
8627 * PCI Tx retries from interfering with C3 CPU state */
8628 pci_write_config_byte(pdev, 0x41, 0x00);
8629
8630 priv->hw_base = pci_iomap(pdev, 0, 0);
8631 if (!priv->hw_base) {
8632 err = -ENODEV;
8633 goto out_pci_release_regions;
8634 }
8635
8636 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n",
8637 (unsigned long long) pci_resource_len(pdev, 0));
8638 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base);
8639
8640 /* Initialize module parameter values here */
8641
8642 /* Disable radio (SW RF KILL) via parameter when loading driver */
8643 if (iwl4965_param_disable) {
8644 set_bit(STATUS_RF_KILL_SW, &priv->status);
8645 IWL_DEBUG_INFO("Radio disabled.\n");
8646 }
8647
8648 priv->iw_mode = IEEE80211_IF_TYPE_STA; 8687 priv->iw_mode = IEEE80211_IF_TYPE_STA;
8649 8688
8650 priv->ps_mode = 0;
8651 priv->use_ant_b_for_management_frame = 1; /* start with ant B */ 8689 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
8652 priv->valid_antenna = 0x7; /* assume all 3 connected */ 8690 priv->valid_antenna = 0x7; /* assume all 3 connected */
8653 priv->ps_mode = IWL_MIMO_PS_NONE; 8691 priv->ps_mode = IWL_MIMO_PS_NONE;
@@ -8655,73 +8693,22 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8655 /* Choose which receivers/antennas to use */ 8693 /* Choose which receivers/antennas to use */
8656 iwl4965_set_rxon_chain(priv); 8694 iwl4965_set_rxon_chain(priv);
8657 8695
8658
8659 printk(KERN_INFO DRV_NAME
8660 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
8661
8662 /* Device-specific setup */
8663 if (iwl4965_hw_set_hw_setting(priv)) {
8664 IWL_ERROR("failed to set hw settings\n");
8665 goto out_iounmap;
8666 }
8667
8668 if (iwl4965_param_qos_enable)
8669 priv->qos_data.qos_enable = 1;
8670
8671 iwl4965_reset_qos(priv); 8696 iwl4965_reset_qos(priv);
8672 8697
8673 priv->qos_data.qos_active = 0; 8698 priv->qos_data.qos_active = 0;
8674 priv->qos_data.qos_cap.val = 0; 8699 priv->qos_data.qos_cap.val = 0;
8675 8700
8676 iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 8701 iwl4965_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
8677 iwl4965_setup_deferred_work(priv);
8678 iwl4965_setup_rx_handlers(priv);
8679 8702
8680 priv->rates_mask = IWL_RATES_MASK; 8703 priv->rates_mask = IWL_RATES_MASK;
8681 /* If power management is turned on, default to AC mode */ 8704 /* If power management is turned on, default to AC mode */
8682 priv->power_mode = IWL_POWER_AC; 8705 priv->power_mode = IWL_POWER_AC;
8683 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER; 8706 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
8684 8707
8685 iwl4965_disable_interrupts(priv);
8686
8687 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8688 if (err) {
8689 IWL_ERROR("failed to create sysfs device attributes\n");
8690 goto out_release_irq;
8691 }
8692
8693 err = iwl_dbgfs_register(priv, DRV_NAME);
8694 if (err) {
8695 IWL_ERROR("failed to create debugfs files\n");
8696 goto out_remove_sysfs;
8697 }
8698 /* nic init */
8699 iwl4965_set_bit(priv, CSR_GIO_CHICKEN_BITS,
8700 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
8701
8702 iwl4965_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
8703 err = iwl4965_poll_bit(priv, CSR_GP_CNTRL,
8704 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
8705 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
8706 if (err < 0) {
8707 IWL_DEBUG_INFO("Failed to init the card\n");
8708 goto out_remove_dbgfs;
8709 }
8710 /* Read the EEPROM */
8711 err = iwl_eeprom_init(priv);
8712 if (err) {
8713 IWL_ERROR("Unable to init EEPROM\n");
8714 goto out_remove_dbgfs;
8715 }
8716 /* MAC Address location in EEPROM same for 3945/4965 */
8717 iwl_eeprom_get_mac(priv, priv->mac_addr);
8718 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
8719 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8720
8721 err = iwl4965_init_channel_map(priv); 8708 err = iwl4965_init_channel_map(priv);
8722 if (err) { 8709 if (err) {
8723 IWL_ERROR("initializing regulatory failed: %d\n", err); 8710 IWL_ERROR("initializing regulatory failed: %d\n", err);
8724 goto out_remove_dbgfs; 8711 goto out_unset_hw_settings;
8725 } 8712 }
8726 8713
8727 err = iwl4965_init_geos(priv); 8714 err = iwl4965_init_geos(priv);
@@ -8739,32 +8726,63 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8739 8726
8740 priv->hw->conf.beacon_int = 100; 8727 priv->hw->conf.beacon_int = 100;
8741 priv->mac80211_registered = 1; 8728 priv->mac80211_registered = 1;
8729
8730 /**********************************
8731 * 7. Initialize module parameters
8732 **********************************/
8733
8734 /* Disable radio (SW RF KILL) via parameter when loading driver */
8735 if (iwl4965_param_disable) {
8736 set_bit(STATUS_RF_KILL_SW, &priv->status);
8737 IWL_DEBUG_INFO("Radio disabled.\n");
8738 }
8739
8740 if (iwl4965_param_qos_enable)
8741 priv->qos_data.qos_enable = 1;
8742
8743 /********************
8744 * 8. Setup services
8745 ********************/
8746 iwl4965_disable_interrupts(priv);
8747
8748 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8749 if (err) {
8750 IWL_ERROR("failed to create sysfs device attributes\n");
8751 goto out_free_geos;
8752 }
8753
8754 err = iwl_dbgfs_register(priv, DRV_NAME);
8755 if (err) {
8756 IWL_ERROR("failed to create debugfs files\n");
8757 goto out_remove_sysfs;
8758 }
8759
8760 iwl4965_setup_deferred_work(priv);
8761 iwl4965_setup_rx_handlers(priv);
8762
8763 /********************
8764 * 9. Conclude
8765 ********************/
8742 pci_save_state(pdev); 8766 pci_save_state(pdev);
8743 pci_disable_device(pdev); 8767 pci_disable_device(pdev);
8744 8768
8745 return 0; 8769 return 0;
8746 8770
8771 out_remove_sysfs:
8772 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8747 out_free_geos: 8773 out_free_geos:
8748 iwl4965_free_geos(priv); 8774 iwl4965_free_geos(priv);
8749 out_free_channel_map: 8775 out_free_channel_map:
8750 iwl4965_free_channel_map(priv); 8776 iwl4965_free_channel_map(priv);
8751 out_remove_dbgfs: 8777 out_unset_hw_settings:
8752 iwl_dbgfs_unregister(priv);
8753 out_remove_sysfs:
8754 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
8755
8756 out_release_irq:
8757 destroy_workqueue(priv->workqueue);
8758 priv->workqueue = NULL;
8759 iwl4965_unset_hw_setting(priv); 8778 iwl4965_unset_hw_setting(priv);
8760
8761 out_iounmap: 8779 out_iounmap:
8762 pci_iounmap(pdev, priv->hw_base); 8780 pci_iounmap(pdev, priv->hw_base);
8763 out_pci_release_regions: 8781 out_pci_release_regions:
8764 pci_release_regions(pdev); 8782 pci_release_regions(pdev);
8783 pci_set_drvdata(pdev, NULL);
8765 out_pci_disable_device: 8784 out_pci_disable_device:
8766 pci_disable_device(pdev); 8785 pci_disable_device(pdev);
8767 pci_set_drvdata(pdev, NULL);
8768 out_ieee80211_free_hw: 8786 out_ieee80211_free_hw:
8769 ieee80211_free_hw(priv->hw); 8787 ieee80211_free_hw(priv->hw);
8770 out: 8788 out: