diff options
author | Kolekar, Abhijeet <abhijeet.kolekar@intel.com> | 2008-11-12 16:14:04 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-25 16:35:20 -0500 |
commit | cee53ddb46eb520079335d0868d0e81c8d311089 (patch) | |
tree | 873f05414ed754da53a44f736b4e08e8d4629dc1 /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | 0e3de99846489424c2cba952e0a52c269f01009a (diff) |
iwl3945 : Simplify iwl3945_pci_probe
Patch aligns iwl3945_pci_probe with iwlwifi's iwl_pci_probe.
Added few comments and code simplified to make readable.
Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@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 | 195 |
1 files changed, 117 insertions, 78 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 3344841b7662..18d2a2a68959 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -7787,6 +7787,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7787 | struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); | 7787 | struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); |
7788 | unsigned long flags; | 7788 | unsigned long flags; |
7789 | 7789 | ||
7790 | /*********************** | ||
7791 | * 1. Allocating HW data | ||
7792 | * ********************/ | ||
7793 | |||
7790 | /* Disabling hardware scan means that mac80211 will perform scans | 7794 | /* Disabling hardware scan means that mac80211 will perform scans |
7791 | * "the hard way", rather than using device's scan. */ | 7795 | * "the hard way", rather than using device's scan. */ |
7792 | if (iwl3945_param_disable_hw_scan) { | 7796 | if (iwl3945_param_disable_hw_scan) { |
@@ -7810,27 +7814,24 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7810 | err = -ENOMEM; | 7814 | err = -ENOMEM; |
7811 | goto out; | 7815 | goto out; |
7812 | } | 7816 | } |
7813 | SET_IEEE80211_DEV(hw, &pdev->dev); | ||
7814 | 7817 | ||
7815 | hw->rate_control_algorithm = "iwl-3945-rs"; | 7818 | SET_IEEE80211_DEV(hw, &pdev->dev); |
7816 | hw->sta_data_size = sizeof(struct iwl3945_sta_priv); | ||
7817 | 7819 | ||
7818 | IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); | ||
7819 | priv = hw->priv; | 7820 | priv = hw->priv; |
7820 | priv->hw = hw; | 7821 | priv->hw = hw; |
7821 | |||
7822 | priv->pci_dev = pdev; | 7822 | priv->pci_dev = pdev; |
7823 | priv->cfg = cfg; | 7823 | priv->cfg = cfg; |
7824 | 7824 | ||
7825 | IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); | ||
7826 | hw->rate_control_algorithm = "iwl-3945-rs"; | ||
7827 | hw->sta_data_size = sizeof(struct iwl3945_sta_priv); | ||
7828 | |||
7825 | /* Select antenna (may be helpful if only one antenna is connected) */ | 7829 | /* Select antenna (may be helpful if only one antenna is connected) */ |
7826 | priv->antenna = (enum iwl3945_antenna)iwl3945_param_antenna; | 7830 | priv->antenna = (enum iwl3945_antenna)iwl3945_param_antenna; |
7827 | #ifdef CONFIG_IWL3945_DEBUG | 7831 | #ifdef CONFIG_IWL3945_DEBUG |
7828 | iwl3945_debug_level = iwl3945_param_debug; | 7832 | iwl3945_debug_level = iwl3945_param_debug; |
7829 | atomic_set(&priv->restrict_refcnt, 0); | 7833 | atomic_set(&priv->restrict_refcnt, 0); |
7830 | #endif | 7834 | #endif |
7831 | priv->retry_rate = 1; | ||
7832 | |||
7833 | priv->ibss_beacon = NULL; | ||
7834 | 7835 | ||
7835 | /* Tell mac80211 our characteristics */ | 7836 | /* Tell mac80211 our characteristics */ |
7836 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | 7837 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
@@ -7844,14 +7845,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7844 | /* 4 EDCA QOS priorities */ | 7845 | /* 4 EDCA QOS priorities */ |
7845 | hw->queues = 4; | 7846 | hw->queues = 4; |
7846 | 7847 | ||
7847 | spin_lock_init(&priv->lock); | 7848 | /*************************** |
7848 | spin_lock_init(&priv->power_data.lock); | 7849 | * 2. Initializing PCI bus |
7849 | spin_lock_init(&priv->sta_lock); | 7850 | * *************************/ |
7850 | spin_lock_init(&priv->hcmd_lock); | ||
7851 | |||
7852 | INIT_LIST_HEAD(&priv->free_frames); | ||
7853 | |||
7854 | mutex_init(&priv->mutex); | ||
7855 | if (pci_enable_device(pdev)) { | 7851 | if (pci_enable_device(pdev)) { |
7856 | err = -ENODEV; | 7852 | err = -ENODEV; |
7857 | goto out_ieee80211_free_hw; | 7853 | goto out_ieee80211_free_hw; |
@@ -7859,14 +7855,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7859 | 7855 | ||
7860 | pci_set_master(pdev); | 7856 | pci_set_master(pdev); |
7861 | 7857 | ||
7862 | /* Clear the driver's (not device's) station table */ | ||
7863 | iwl3945_clear_stations_table(priv); | ||
7864 | |||
7865 | priv->data_retry_limit = -1; | ||
7866 | priv->ieee_channels = NULL; | ||
7867 | priv->ieee_rates = NULL; | ||
7868 | priv->band = IEEE80211_BAND_2GHZ; | ||
7869 | |||
7870 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 7858 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
7871 | if (!err) | 7859 | if (!err) |
7872 | err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 7860 | err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
@@ -7880,10 +7868,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7880 | if (err) | 7868 | if (err) |
7881 | goto out_pci_disable_device; | 7869 | goto out_pci_disable_device; |
7882 | 7870 | ||
7883 | /* We disable the RETRY_TIMEOUT register (0x41) to keep | 7871 | /*********************** |
7884 | * PCI Tx retries from interfering with C3 CPU state */ | 7872 | * 3. Read REV Register |
7885 | pci_write_config_byte(pdev, 0x41, 0x00); | 7873 | * ********************/ |
7886 | |||
7887 | priv->hw_base = pci_iomap(pdev, 0, 0); | 7874 | priv->hw_base = pci_iomap(pdev, 0, 0); |
7888 | if (!priv->hw_base) { | 7875 | if (!priv->hw_base) { |
7889 | err = -ENODEV; | 7876 | err = -ENODEV; |
@@ -7894,25 +7881,70 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7894 | (unsigned long long) pci_resource_len(pdev, 0)); | 7881 | (unsigned long long) pci_resource_len(pdev, 0)); |
7895 | IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); | 7882 | IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); |
7896 | 7883 | ||
7897 | /* Initialize module parameter values here */ | 7884 | /* We disable the RETRY_TIMEOUT register (0x41) to keep |
7885 | * PCI Tx retries from interfering with C3 CPU state */ | ||
7886 | pci_write_config_byte(pdev, 0x41, 0x00); | ||
7898 | 7887 | ||
7899 | /* Disable radio (SW RF KILL) via parameter when loading driver */ | 7888 | /* nic init */ |
7900 | if (iwl3945_param_disable) { | 7889 | iwl3945_set_bit(priv, CSR_GIO_CHICKEN_BITS, |
7901 | set_bit(STATUS_RF_KILL_SW, &priv->status); | 7890 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); |
7902 | IWL_DEBUG_INFO("Radio disabled.\n"); | ||
7903 | } | ||
7904 | 7891 | ||
7905 | priv->iw_mode = NL80211_IFTYPE_STATION; | 7892 | iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
7893 | err = iwl3945_poll_bit(priv, CSR_GP_CNTRL, | ||
7894 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | ||
7895 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); | ||
7896 | if (err < 0) { | ||
7897 | IWL_DEBUG_INFO("Failed to init the card\n"); | ||
7898 | goto out_remove_sysfs; | ||
7899 | } | ||
7906 | 7900 | ||
7907 | printk(KERN_INFO DRV_NAME | 7901 | /*********************** |
7908 | ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); | 7902 | * 4. Read EEPROM |
7903 | * ********************/ | ||
7904 | /* Read the EEPROM */ | ||
7905 | err = iwl3945_eeprom_init(priv); | ||
7906 | if (err) { | ||
7907 | IWL_ERROR("Unable to init EEPROM\n"); | ||
7908 | goto out_remove_sysfs; | ||
7909 | } | ||
7910 | /* MAC Address location in EEPROM same for 3945/4965 */ | ||
7911 | get_eeprom_mac(priv, priv->mac_addr); | ||
7912 | IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); | ||
7913 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); | ||
7909 | 7914 | ||
7915 | /*********************** | ||
7916 | * 5. Setup HW Constants | ||
7917 | * ********************/ | ||
7910 | /* Device-specific setup */ | 7918 | /* Device-specific setup */ |
7911 | if (iwl3945_hw_set_hw_setting(priv)) { | 7919 | if (iwl3945_hw_set_hw_setting(priv)) { |
7912 | IWL_ERROR("failed to set hw settings\n"); | 7920 | IWL_ERROR("failed to set hw settings\n"); |
7913 | goto out_iounmap; | 7921 | goto out_iounmap; |
7914 | } | 7922 | } |
7915 | 7923 | ||
7924 | /*********************** | ||
7925 | * 6. Setup priv | ||
7926 | * ********************/ | ||
7927 | priv->retry_rate = 1; | ||
7928 | priv->ibss_beacon = NULL; | ||
7929 | |||
7930 | spin_lock_init(&priv->lock); | ||
7931 | spin_lock_init(&priv->power_data.lock); | ||
7932 | spin_lock_init(&priv->sta_lock); | ||
7933 | spin_lock_init(&priv->hcmd_lock); | ||
7934 | |||
7935 | INIT_LIST_HEAD(&priv->free_frames); | ||
7936 | mutex_init(&priv->mutex); | ||
7937 | |||
7938 | /* Clear the driver's (not device's) station table */ | ||
7939 | iwl3945_clear_stations_table(priv); | ||
7940 | |||
7941 | priv->data_retry_limit = -1; | ||
7942 | priv->ieee_channels = NULL; | ||
7943 | priv->ieee_rates = NULL; | ||
7944 | priv->band = IEEE80211_BAND_2GHZ; | ||
7945 | |||
7946 | priv->iw_mode = NL80211_IFTYPE_STATION; | ||
7947 | |||
7916 | if (iwl3945_param_qos_enable) | 7948 | if (iwl3945_param_qos_enable) |
7917 | priv->qos_data.qos_enable = 1; | 7949 | priv->qos_data.qos_enable = 1; |
7918 | 7950 | ||
@@ -7921,70 +7953,76 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7921 | priv->qos_data.qos_active = 0; | 7953 | priv->qos_data.qos_active = 0; |
7922 | priv->qos_data.qos_cap.val = 0; | 7954 | priv->qos_data.qos_cap.val = 0; |
7923 | 7955 | ||
7924 | iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); | ||
7925 | iwl3945_setup_deferred_work(priv); | ||
7926 | iwl3945_setup_rx_handlers(priv); | ||
7927 | 7956 | ||
7928 | priv->rates_mask = IWL_RATES_MASK; | 7957 | priv->rates_mask = IWL_RATES_MASK; |
7929 | /* If power management is turned on, default to AC mode */ | 7958 | /* If power management is turned on, default to AC mode */ |
7930 | priv->power_mode = IWL_POWER_AC; | 7959 | priv->power_mode = IWL_POWER_AC; |
7931 | priv->user_txpower_limit = IWL_DEFAULT_TX_POWER; | 7960 | priv->user_txpower_limit = IWL_DEFAULT_TX_POWER; |
7932 | 7961 | ||
7933 | spin_lock_irqsave(&priv->lock, flags); | 7962 | err = iwl3945_init_channel_map(priv); |
7934 | iwl3945_disable_interrupts(priv); | ||
7935 | spin_unlock_irqrestore(&priv->lock, flags); | ||
7936 | |||
7937 | err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); | ||
7938 | if (err) { | 7963 | if (err) { |
7939 | IWL_ERROR("failed to create sysfs device attributes\n"); | 7964 | IWL_ERROR("initializing regulatory failed: %d\n", err); |
7940 | goto out_release_irq; | 7965 | goto out_release_irq; |
7941 | } | 7966 | } |
7942 | 7967 | ||
7943 | /* nic init */ | 7968 | err = iwl3945_init_geos(priv); |
7944 | iwl3945_set_bit(priv, CSR_GIO_CHICKEN_BITS, | ||
7945 | CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); | ||
7946 | |||
7947 | iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | ||
7948 | err = iwl3945_poll_bit(priv, CSR_GP_CNTRL, | ||
7949 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, | ||
7950 | CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); | ||
7951 | if (err < 0) { | ||
7952 | IWL_DEBUG_INFO("Failed to init the card\n"); | ||
7953 | goto out_remove_sysfs; | ||
7954 | } | ||
7955 | /* Read the EEPROM */ | ||
7956 | err = iwl3945_eeprom_init(priv); | ||
7957 | if (err) { | 7969 | if (err) { |
7958 | IWL_ERROR("Unable to init EEPROM\n"); | 7970 | IWL_ERROR("initializing geos failed: %d\n", err); |
7959 | goto out_remove_sysfs; | 7971 | goto out_free_channel_map; |
7960 | } | 7972 | } |
7961 | /* MAC Address location in EEPROM same for 3945/4965 */ | ||
7962 | get_eeprom_mac(priv, priv->mac_addr); | ||
7963 | IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); | ||
7964 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); | ||
7965 | 7973 | ||
7966 | err = iwl3945_init_channel_map(priv); | 7974 | printk(KERN_INFO DRV_NAME |
7967 | if (err) { | 7975 | ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); |
7968 | IWL_ERROR("initializing regulatory failed: %d\n", err); | 7976 | |
7969 | goto out_remove_sysfs; | 7977 | /*********************************** |
7978 | * 7. Initialize Module Parameters | ||
7979 | * **********************************/ | ||
7980 | |||
7981 | /* Initialize module parameter values here */ | ||
7982 | /* Disable radio (SW RF KILL) via parameter when loading driver */ | ||
7983 | if (iwl3945_param_disable) { | ||
7984 | set_bit(STATUS_RF_KILL_SW, &priv->status); | ||
7985 | IWL_DEBUG_INFO("Radio disabled.\n"); | ||
7970 | } | 7986 | } |
7971 | 7987 | ||
7972 | err = iwl3945_init_geos(priv); | 7988 | |
7989 | /*********************** | ||
7990 | * 8. Setup Services | ||
7991 | * ********************/ | ||
7992 | |||
7993 | spin_lock_irqsave(&priv->lock, flags); | ||
7994 | iwl3945_disable_interrupts(priv); | ||
7995 | spin_unlock_irqrestore(&priv->lock, flags); | ||
7996 | |||
7997 | err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); | ||
7973 | if (err) { | 7998 | if (err) { |
7974 | IWL_ERROR("initializing geos failed: %d\n", err); | 7999 | IWL_ERROR("failed to create sysfs device attributes\n"); |
7975 | goto out_free_channel_map; | 8000 | goto out_free_geos; |
7976 | } | 8001 | } |
7977 | 8002 | ||
8003 | iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); | ||
8004 | iwl3945_setup_deferred_work(priv); | ||
8005 | iwl3945_setup_rx_handlers(priv); | ||
8006 | |||
8007 | /*********************** | ||
8008 | * 9. Conclude | ||
8009 | * ********************/ | ||
8010 | pci_save_state(pdev); | ||
8011 | pci_disable_device(pdev); | ||
8012 | |||
8013 | /********************************* | ||
8014 | * 10. Setup and Register mac80211 | ||
8015 | * *******************************/ | ||
8016 | |||
7978 | err = ieee80211_register_hw(priv->hw); | 8017 | err = ieee80211_register_hw(priv->hw); |
7979 | if (err) { | 8018 | if (err) { |
7980 | IWL_ERROR("Failed to register network device (error %d)\n", err); | 8019 | IWL_ERROR("Failed to register network device (error %d)\n", err); |
7981 | goto out_free_geos; | 8020 | goto out_remove_sysfs; |
7982 | } | 8021 | } |
7983 | 8022 | ||
7984 | priv->hw->conf.beacon_int = 100; | 8023 | priv->hw->conf.beacon_int = 100; |
7985 | priv->mac80211_registered = 1; | 8024 | priv->mac80211_registered = 1; |
7986 | pci_save_state(pdev); | 8025 | |
7987 | pci_disable_device(pdev); | ||
7988 | 8026 | ||
7989 | err = iwl3945_rfkill_init(priv); | 8027 | err = iwl3945_rfkill_init(priv); |
7990 | if (err) | 8028 | if (err) |
@@ -7993,12 +8031,13 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7993 | 8031 | ||
7994 | return 0; | 8032 | return 0; |
7995 | 8033 | ||
8034 | out_remove_sysfs: | ||
8035 | sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); | ||
7996 | out_free_geos: | 8036 | out_free_geos: |
7997 | iwl3945_free_geos(priv); | 8037 | iwl3945_free_geos(priv); |
7998 | out_free_channel_map: | 8038 | out_free_channel_map: |
7999 | iwl3945_free_channel_map(priv); | 8039 | iwl3945_free_channel_map(priv); |
8000 | out_remove_sysfs: | 8040 | |
8001 | sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); | ||
8002 | 8041 | ||
8003 | out_release_irq: | 8042 | out_release_irq: |
8004 | destroy_workqueue(priv->workqueue); | 8043 | destroy_workqueue(priv->workqueue); |