Commit 90a30a02 authored by Kolekar, Abhijeet's avatar Kolekar, Abhijeet Committed by John W. Linville

iwl3945: simplify iwl3945_pci_probe

The patch simplifies iwl3945_pci_probe. It also uses apm_ops for apm init.
Signed-off-by: default avatarAbhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: default avatarZhu Yi <yi.zhu@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 854682ed
...@@ -7422,6 +7422,62 @@ static struct ieee80211_ops iwl3945_hw_ops = { ...@@ -7422,6 +7422,62 @@ static struct ieee80211_ops iwl3945_hw_ops = {
.hw_scan = iwl3945_mac_hw_scan .hw_scan = iwl3945_mac_hw_scan
}; };
int iwl3945_init_drv(struct iwl_priv *priv)
{
int ret;
priv->retry_rate = 1;
priv->ibss_beacon = NULL;
spin_lock_init(&priv->lock);
spin_lock_init(&priv->power_data.lock);
spin_lock_init(&priv->sta_lock);
spin_lock_init(&priv->hcmd_lock);
INIT_LIST_HEAD(&priv->free_frames);
mutex_init(&priv->mutex);
/* Clear the driver's (not device's) station table */
iwl3945_clear_stations_table(priv);
priv->data_retry_limit = -1;
priv->ieee_channels = NULL;
priv->ieee_rates = NULL;
priv->band = IEEE80211_BAND_2GHZ;
priv->iw_mode = NL80211_IFTYPE_STATION;
iwl_reset_qos(priv);
priv->qos_data.qos_active = 0;
priv->qos_data.qos_cap.val = 0;
priv->rates_mask = IWL_RATES_MASK;
/* If power management is turned on, default to AC mode */
priv->power_mode = IWL_POWER_AC;
priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
ret = iwl3945_init_channel_map(priv);
if (ret) {
IWL_ERR(priv, "initializing regulatory failed: %d\n", ret);
goto err;
}
ret = iwl3945_init_geos(priv);
if (ret) {
IWL_ERR(priv, "initializing geos failed: %d\n", ret);
goto err_free_channel_map;
}
return 0;
err_free_channel_map:
iwl3945_free_channel_map(priv);
err:
return ret;
}
static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
int err = 0; int err = 0;
...@@ -7436,19 +7492,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e ...@@ -7436,19 +7492,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
/* mac80211 allocates memory for this device instance, including /* mac80211 allocates memory for this device instance, including
* space for this driver's private structure */ * space for this driver's private structure */
hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwl3945_hw_ops); hw = iwl_alloc_all(cfg, &iwl3945_hw_ops);
if (hw == NULL) { if (hw == NULL) {
printk(KERN_ERR DRV_NAME "Can not allocate network device\n"); printk(KERN_ERR DRV_NAME "Can not allocate network device\n");
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
SET_IEEE80211_DEV(hw, &pdev->dev);
priv = hw->priv; priv = hw->priv;
priv->hw = hw; SET_IEEE80211_DEV(hw, &pdev->dev);
priv->pci_dev = pdev;
priv->cfg = cfg;
if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) || if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) ||
(iwl3945_mod_params.num_of_queues < IWL_MIN_NUM_QUEUES)) { (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,23 +7510,29 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
goto out; goto out;
} }
/* Disabling hardware scan means that mac80211 will perform scans /*
* "the hard way", rather than using device's scan. */ * Disabling hardware scan means that mac80211 will perform scans
* "the hard way", rather than using device's scan.
*/
if (iwl3945_mod_params.disable_hw_scan) { if (iwl3945_mod_params.disable_hw_scan) {
IWL_DEBUG_INFO("Disabling hw_scan\n"); IWL_DEBUG_INFO("Disabling hw_scan\n");
iwl3945_hw_ops.hw_scan = NULL; iwl3945_hw_ops.hw_scan = NULL;
} }
IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
hw->rate_control_algorithm = "iwl-3945-rs"; priv->cfg = cfg;
hw->sta_data_size = sizeof(struct iwl3945_sta_priv); priv->pci_dev = pdev;
/* Select antenna (may be helpful if only one antenna is connected) */
priv->antenna = (enum iwl3945_antenna)iwl3945_mod_params.antenna;
#ifdef CONFIG_IWL3945_DEBUG #ifdef CONFIG_IWL3945_DEBUG
priv->debug_level = iwl3945_mod_params.debug; priv->debug_level = iwl3945_mod_params.debug;
atomic_set(&priv->restrict_refcnt, 0); atomic_set(&priv->restrict_refcnt, 0);
#endif #endif
hw->rate_control_algorithm = "iwl-3945-rs";
hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
/* Select antenna (may be helpful if only one antenna is connected) */
priv->antenna = (enum iwl3945_antenna)iwl3945_mod_params.antenna;
/* Tell mac80211 our characteristics */ /* Tell mac80211 our characteristics */
hw->flags = IEEE80211_HW_SIGNAL_DBM | 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,21 +7587,17 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
* PCI Tx retries from interfering with C3 CPU state */ * PCI Tx retries from interfering with C3 CPU state */
pci_write_config_byte(pdev, 0x41, 0x00); pci_write_config_byte(pdev, 0x41, 0x00);
/* nic init */ /* amp init */
iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, err = priv->cfg->ops->lib->apm_ops.init(priv);
CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
err = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
if (err < 0) { if (err < 0) {
IWL_DEBUG_INFO("Failed to init the APMG\n"); IWL_DEBUG_INFO("Failed to init APMG\n");
goto out_remove_sysfs; goto out_iounmap;
} }
/*********************** /***********************
* 4. Read EEPROM * 4. Read EEPROM
* ********************/ * ********************/
/* Read the EEPROM */ /* Read the EEPROM */
err = iwl3945_eeprom_init(priv); err = iwl3945_eeprom_init(priv);
if (err) { if (err) {
...@@ -7568,48 +7621,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e ...@@ -7568,48 +7621,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
/*********************** /***********************
* 6. Setup priv * 6. Setup priv
* ********************/ * ********************/
priv->retry_rate = 1;
priv->ibss_beacon = NULL;
spin_lock_init(&priv->lock);
spin_lock_init(&priv->power_data_39.lock);
spin_lock_init(&priv->sta_lock);
spin_lock_init(&priv->hcmd_lock);
INIT_LIST_HEAD(&priv->free_frames);
mutex_init(&priv->mutex);
/* Clear the driver's (not device's) station table */
iwl3945_clear_stations_table(priv);
priv->data_retry_limit = -1; err = iwl3945_init_drv(priv);
priv->ieee_channels = NULL;
priv->ieee_rates = NULL;
priv->band = IEEE80211_BAND_2GHZ;
priv->iw_mode = NL80211_IFTYPE_STATION;
iwl_reset_qos(priv);
priv->qos_data.qos_active = 0;
priv->qos_data.qos_cap.val = 0;
priv->rates_mask = IWL_RATES_MASK;
/* If power management is turned on, default to AC mode */
priv->power_mode = IWL39_POWER_AC;
priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
err = iwl3945_init_channel_map(priv);
if (err) {
IWL_ERR(priv, "initializing regulatory failed: %d\n", err);
goto out_release_irq;
}
err = iwl3945_init_geos(priv);
if (err) { if (err) {
IWL_ERR(priv, "initializing geos failed: %d\n", err); IWL_ERR(priv, "initializing driver failed\n");
goto out_free_channel_map; goto out_free_geos;
} }
IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", 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,7 +7654,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group);
if (err) { if (err) {
IWL_ERR(priv, "failed to create sysfs device attributes\n"); IWL_ERR(priv, "failed to create sysfs device attributes\n");
goto out_free_geos; goto out_release_irq;
} }
iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 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,7 +7680,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
priv->hw->conf.beacon_int = 100; priv->hw->conf.beacon_int = 100;
priv->mac80211_registered = 1; priv->mac80211_registered = 1;
err = iwl3945_rfkill_init(priv); err = iwl3945_rfkill_init(priv);
if (err) if (err)
IWL_ERR(priv, "Unable to initialize RFKILL system. " 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,9 +7691,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
out_free_geos: out_free_geos:
iwl3945_free_geos(priv); iwl3945_free_geos(priv);
out_free_channel_map:
iwl3945_free_channel_map(priv);
out_release_irq: out_release_irq:
destroy_workqueue(priv->workqueue); destroy_workqueue(priv->workqueue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment