From: Zhu Yi <yi.zhu@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
ipw3945-devel@lists.sourceforge.net, "Kolekar,
Abhijeet" <abhijeet.kolekar@intel.com>, Zhu Yi <yi.zhu@intel.com>
Subject: [PATCH 40/43] iwl3945: simplify iwl3945_pci_probe
Date: Fri, 19 Dec 2008 10:37:40 +0800 [thread overview]
Message-ID: <1229654263-21454-41-git-send-email-yi.zhu@intel.com> (raw)
In-Reply-To: <1229654263-21454-40-git-send-email-yi.zhu@intel.com>
From: Kolekar, Abhijeet <abhijeet.kolekar@intel.com>
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>
---
drivers/net/wireless/iwlwifi/iwl3945-base.c | 146 ++++++++++++++------------
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 1446fa6..1d4a474 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -7439,6 +7439,62 @@ static struct ieee80211_ops iwl3945_hw_ops = {
.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)
{
int err = 0;
@@ -7454,19 +7510,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
/* mac80211 allocates memory for this device instance, including
* 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) {
printk(KERN_ERR DRV_NAME "Can not allocate network device\n");
err = -ENOMEM;
goto out;
}
-
- SET_IEEE80211_DEV(hw, &pdev->dev);
-
priv = hw->priv;
- priv->hw = hw;
- priv->pci_dev = pdev;
- priv->cfg = cfg;
+ SET_IEEE80211_DEV(hw, &pdev->dev);
if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) ||
(iwl3945_mod_params.num_of_queues < IWL_MIN_NUM_QUEUES)) {
@@ -7477,23 +7528,29 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
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) {
IWL_DEBUG_INFO("Disabling hw_scan\n");
iwl3945_hw_ops.hw_scan = NULL;
}
+
IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
- hw->rate_control_algorithm = "iwl-3945-rs";
- hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
+ priv->cfg = cfg;
+ 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
priv->debug_level = iwl3945_mod_params.debug;
atomic_set(&priv->restrict_refcnt, 0);
#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 */
hw->flags = IEEE80211_HW_SIGNAL_DBM |
@@ -7548,21 +7605,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_write_config_byte(pdev, 0x41, 0x00);
- /* nic init */
- iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
- 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);
+ /* amp init */
+ err = priv->cfg->ops->lib->apm_ops.init(priv);
if (err < 0) {
- IWL_DEBUG_INFO("Failed to init the APMG\n");
- goto out_remove_sysfs;
+ IWL_DEBUG_INFO("Failed to init APMG\n");
+ goto out_iounmap;
}
/***********************
* 4. Read EEPROM
* ********************/
+
/* Read the EEPROM */
err = iwl3945_eeprom_init(priv);
if (err) {
@@ -7586,48 +7639,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
/***********************
* 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;
- 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);
+ err = iwl3945_init_drv(priv);
if (err) {
- IWL_ERR(priv, "initializing geos failed: %d\n", err);
- goto out_free_channel_map;
+ IWL_ERR(priv, "initializing driver failed\n");
+ goto out_free_geos;
}
IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n",
@@ -7656,7 +7672,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);
if (err) {
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);
@@ -7682,7 +7698,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
priv->hw->conf.beacon_int = 100;
priv->mac80211_registered = 1;
-
err = iwl3945_rfkill_init(priv);
if (err)
IWL_ERR(priv, "Unable to initialize RFKILL system. "
@@ -7694,9 +7709,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);
out_free_geos:
iwl3945_free_geos(priv);
- out_free_channel_map:
- iwl3945_free_channel_map(priv);
-
out_release_irq:
destroy_workqueue(priv->workqueue);
--
1.5.3.6
next prev parent reply other threads:[~2008-12-19 2:45 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-19 2:37 [PATCH 00/43] iwl3945 merges into iwlagn (Dec 19) Zhu Yi
2008-12-19 2:37 ` [PATCH 01/43] iwlwifi: 3945 extract flow handler definitions into iwl-3945-fh.h Zhu Yi
2008-12-19 2:37 ` [PATCH 02/43] iwlwifi: 3945 unfold iwl-3945-commands.h Zhu Yi
2008-12-19 2:37 ` [PATCH 03/43] iwlwifi: 3945 remove current_rate from station entry Zhu Yi
2008-12-19 2:37 ` [PATCH 04/43] iwlwifi: use iwl-commands.h also in 3945 Zhu Yi
2008-12-19 2:37 ` [PATCH 05/43] iwlwifi: 3945 remove duplicated code from iwl-3945-commands.h Zhu Yi
2008-12-19 2:37 ` [PATCH 06/43] iwlwifi: 3945 drop usage of union tsf Zhu Yi
2008-12-19 2:37 ` [PATCH 07/43] iwlwifi: 3945 remove iwl-3945-commands.h Zhu Yi
2008-12-19 2:37 ` [PATCH 08/43] iwl3945: Getting rid of iwl-3945-debug.h Zhu Yi
2008-12-19 2:37 ` [PATCH 09/43] iwl3945: Remove DRV_NAME dependenies Zhu Yi
2008-12-19 2:37 ` [PATCH 10/43] iwl3945: Getting rid of iwl3945_eeprom_channel Zhu Yi
2008-12-19 2:37 ` [PATCH 11/43] iwl3945: Have consistant and not redefined HW constants Zhu Yi
2008-12-19 2:37 ` [PATCH 12/43] iwl3945: Use iwl-agn-rs.h rates definitions Zhu Yi
2008-12-19 2:37 ` [PATCH 13/43] iwl3945: Getting rid of iwl-3945-led.h Zhu Yi
2008-12-19 2:37 ` [PATCH 14/43] iwl3945: Remove power related definitions from 3945 code Zhu Yi
2008-12-19 2:37 ` [PATCH 15/43] iwl3945: iwl3945_queue and iwl3945_channel_info replacement Zhu Yi
2008-12-19 2:37 ` [PATCH 16/43] iwlwifi: emliminate iwl3945_mac_get_stats mac80211 handler Zhu Yi
2008-12-19 2:37 ` [PATCH 17/43] iwl3945: Change IWLWIFI_VERSION constant name Zhu Yi
2008-12-19 2:37 ` [PATCH 18/43] iwl3945: include iwl-core.h Zhu Yi
2008-12-19 2:37 ` [PATCH 19/43] iwl3945: replace iwl_3945_cfg with iwl_cfg Zhu Yi
2008-12-19 2:37 ` [PATCH 20/43] iwl3945: move structures from iwl-3945.h to iwl-dev.h Zhu Yi
2008-12-19 2:37 ` [PATCH 21/43] iwl3945: remove duplicate structures from iwl-3945.h Zhu Yi
2008-12-19 2:37 ` [PATCH 22/43] iwl3945: replace iwl3945_broadcast_addr with iwl_bcast_addr Zhu Yi
2008-12-19 2:37 ` [PATCH 23/43] iwlwifi: beautify code Zhu Yi
2008-12-19 2:37 ` [PATCH 24/43] iwl3945: use iwl_rx_mem_buffer Zhu Yi
2008-12-19 2:37 ` [PATCH 25/43] iwl3945: use iwl_rx_queue in iwl3945 Zhu Yi
2008-12-19 2:37 ` [PATCH 26/43] iwl3945: use iwl_hw_params in iwl3945_priv Zhu Yi
2008-12-19 2:37 ` [PATCH 27/43] iwl3945: rename iwl3945_priv variables Zhu Yi
2008-12-19 2:37 ` [PATCH 28/43] iwl3945: replaces iwl3945_priv with iwl_priv Zhu Yi
2008-12-19 2:37 ` [PATCH 29/43] iwl3945: use iwl-io.h and delete iwl-3945-io.h Zhu Yi
2008-12-19 2:37 ` [PATCH 30/43] iwlwifi: add more comments to IWL_DL_xx Zhu Yi
2008-12-19 2:37 ` [PATCH 31/43] iwlwifi: clean up printing Zhu Yi
2008-12-19 2:37 ` [PATCH 32/43] iwlwifi: replace IWL_WARNING with IWL_WARN Zhu Yi
2008-12-19 2:37 ` [PATCH 33/43] iwlwifi: replace IWL_ERROR with IWL_ERR Zhu Yi
2008-12-19 2:37 ` [PATCH 34/43] iwlwifi: use iwl_cmd instead of iwl3945_cmd Zhu Yi
2008-12-19 2:37 ` [PATCH 35/43] iwl3945: use iwl_mod_params for 3945 Zhu Yi
2008-12-19 2:37 ` [PATCH 36/43] iwl3945: cleanup and remove duplicate code Zhu Yi
2008-12-19 2:37 ` [PATCH 37/43] iwl3945: add load ucode op Zhu Yi
2008-12-19 2:37 ` [PATCH 38/43] iwl3945: add apm ops Zhu Yi
2008-12-19 2:37 ` [PATCH 39/43] iwl3945: add set_pwr_src Zhu Yi
2008-12-19 2:37 ` Zhu Yi [this message]
2008-12-19 2:37 ` [PATCH 41/43] iwl3945: release resources before shutting down Zhu Yi
2008-12-19 2:37 ` [PATCH 42/43] iwl3945: use iwl_get_hw_mode Zhu Yi
2008-12-19 2:37 ` [PATCH 43/43] iwl3945: use iwl_rb_status Zhu Yi
2008-12-19 19:32 ` [PATCH 00/43] iwl3945 merges into iwlagn (Dec 19) drago01
2008-12-19 20:51 ` Luis R. Rodriguez
2008-12-19 21:15 ` drago01
2008-12-19 21:20 ` Stefanik Gábor
2008-12-22 3:55 ` Zhu Yi
2008-12-22 6:57 ` [ipw3945-devel] " Rafał Miłecki
2008-12-19 21:08 ` Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1229654263-21454-41-git-send-email-yi.zhu@intel.com \
--to=yi.zhu@intel.com \
--cc=abhijeet.kolekar@intel.com \
--cc=ipw3945-devel@lists.sourceforge.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox