aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRon Rindjunsky <ron.rindjunsky@intel.com>2008-04-23 20:14:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-07 15:02:17 -0400
commit399f490067992715044cbf2be1923e2f613b2e18 (patch)
tree03db5be67dcde4fdb68cf15e6ccdb52b23efac55 /drivers
parent8614f360bdc7db8d35609a9c771601f1d45539e5 (diff)
iwlwifi: handle shared memory
This patch generalize the use of shared memory, as size of this memory is now allocated and freed by handlers, and also changes the location of those actions for better resource management Signed-off-by: Ron Rindjunsky <ron.rindjunsky@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.c36
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c23
3 files changed, 36 insertions, 27 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index a41a83a5f816..e80f6022cf43 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -276,18 +276,6 @@ static int iwl4965_init_drv(struct iwl_priv *priv)
276 spin_lock_init(&priv->hcmd_lock); 276 spin_lock_init(&priv->hcmd_lock);
277 spin_lock_init(&priv->lq_mngr.lock); 277 spin_lock_init(&priv->lq_mngr.lock);
278 278
279 priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
280 sizeof(struct iwl4965_shared),
281 &priv->shared_phys);
282
283 if (!priv->shared_virt) {
284 ret = -ENOMEM;
285 goto err;
286 }
287
288 memset(priv->shared_virt, 0, sizeof(struct iwl4965_shared));
289
290
291 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++) 279 for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
292 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]); 280 INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
293 281
@@ -2492,6 +2480,28 @@ static void iwl4965_hw_card_show_info(struct iwl_priv *priv)
2492 &priv->eeprom[EEPROM_4965_BOARD_PBA]); 2480 &priv->eeprom[EEPROM_4965_BOARD_PBA]);
2493} 2481}
2494 2482
2483static int iwl4965_alloc_shared_mem(struct iwl_priv *priv)
2484{
2485 priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
2486 sizeof(struct iwl4965_shared),
2487 &priv->shared_phys);
2488 if (!priv->shared_virt)
2489 return -ENOMEM;
2490
2491 memset(priv->shared_virt, 0, sizeof(struct iwl4965_shared));
2492
2493 return 0;
2494}
2495
2496static void iwl4965_free_shared_mem(struct iwl_priv *priv)
2497{
2498 if (priv->shared_virt)
2499 pci_free_consistent(priv->pci_dev,
2500 sizeof(struct iwl4965_shared),
2501 priv->shared_virt,
2502 priv->shared_phys);
2503}
2504
2495#define IWL_TX_CRC_SIZE 4 2505#define IWL_TX_CRC_SIZE 4
2496#define IWL_TX_DELIMITER_SIZE 4 2506#define IWL_TX_DELIMITER_SIZE 4
2497 2507
@@ -4351,6 +4361,8 @@ static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
4351static struct iwl_lib_ops iwl4965_lib = { 4361static struct iwl_lib_ops iwl4965_lib = {
4352 .init_drv = iwl4965_init_drv, 4362 .init_drv = iwl4965_init_drv,
4353 .set_hw_params = iwl4965_hw_set_hw_params, 4363 .set_hw_params = iwl4965_hw_set_hw_params,
4364 .alloc_shared_mem = iwl4965_alloc_shared_mem,
4365 .free_shared_mem = iwl4965_free_shared_mem,
4354 .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, 4366 .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl,
4355 .hw_nic_init = iwl4965_hw_nic_init, 4367 .hw_nic_init = iwl4965_hw_nic_init,
4356 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, 4368 .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index eff076e3521c..e94aea3cba7c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -101,7 +101,9 @@ struct iwl_lib_ops {
101 int (*init_drv)(struct iwl_priv *priv); 101 int (*init_drv)(struct iwl_priv *priv);
102 /* set hw dependant perameters */ 102 /* set hw dependant perameters */
103 int (*set_hw_params)(struct iwl_priv *priv); 103 int (*set_hw_params)(struct iwl_priv *priv);
104 104 /* ucode shared memory */
105 int (*alloc_shared_mem)(struct iwl_priv *priv);
106 void (*free_shared_mem)(struct iwl_priv *priv);
105 void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, 107 void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv,
106 struct iwl4965_tx_queue *txq, 108 struct iwl4965_tx_queue *txq,
107 u16 byte_cnt); 109 u16 byte_cnt);
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index c532584b11e6..783f722f3c35 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -1128,15 +1128,6 @@ static int iwl4965_send_beacon_cmd(struct iwl_priv *priv)
1128 * 1128 *
1129 ******************************************************************************/ 1129 ******************************************************************************/
1130 1130
1131static void iwl4965_unset_hw_params(struct iwl_priv *priv)
1132{
1133 if (priv->shared_virt)
1134 pci_free_consistent(priv->pci_dev,
1135 sizeof(struct iwl4965_shared),
1136 priv->shared_virt,
1137 priv->shared_phys);
1138}
1139
1140/** 1131/**
1141 * iwl4965_supported_rate_to_ie - fill in the supported rate in IE field 1132 * iwl4965_supported_rate_to_ie - fill in the supported rate in IE field
1142 * 1133 *
@@ -5298,6 +5289,7 @@ static void __iwl4965_down(struct iwl_priv *priv)
5298 iwl4965_hw_nic_stop_master(priv); 5289 iwl4965_hw_nic_stop_master(priv);
5299 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 5290 iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
5300 iwl4965_hw_nic_reset(priv); 5291 iwl4965_hw_nic_reset(priv);
5292 priv->cfg->ops->lib->free_shared_mem(priv);
5301 5293
5302 exit: 5294 exit:
5303 memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp)); 5295 memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp));
@@ -5359,6 +5351,12 @@ static int __iwl4965_up(struct iwl_priv *priv)
5359 iwl_rfkill_set_hw_state(priv); 5351 iwl_rfkill_set_hw_state(priv);
5360 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 5352 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
5361 5353
5354 ret = priv->cfg->ops->lib->alloc_shared_mem(priv);
5355 if (ret) {
5356 IWL_ERROR("Unable to allocate shared memory\n");
5357 return ret;
5358 }
5359
5362 ret = priv->cfg->ops->lib->hw_nic_init(priv); 5360 ret = priv->cfg->ops->lib->hw_nic_init(priv);
5363 if (ret) { 5361 if (ret) {
5364 IWL_ERROR("Unable to init nic\n"); 5362 IWL_ERROR("Unable to init nic\n");
@@ -7503,7 +7501,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7503 7501
7504 err = iwl_setup(priv); 7502 err = iwl_setup(priv);
7505 if (err) 7503 if (err)
7506 goto out_unset_hw_params; 7504 goto out_free_eeprom;
7507 /* At this point both hw and priv are initialized. */ 7505 /* At this point both hw and priv are initialized. */
7508 7506
7509 /********************************** 7507 /**********************************
@@ -7529,7 +7527,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7529 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group); 7527 err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
7530 if (err) { 7528 if (err) {
7531 IWL_ERROR("failed to create sysfs device attributes\n"); 7529 IWL_ERROR("failed to create sysfs device attributes\n");
7532 goto out_unset_hw_params; 7530 goto out_free_eeprom;
7533 } 7531 }
7534 7532
7535 err = iwl_dbgfs_register(priv, DRV_NAME); 7533 err = iwl_dbgfs_register(priv, DRV_NAME);
@@ -7553,8 +7551,6 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7553 7551
7554 out_remove_sysfs: 7552 out_remove_sysfs:
7555 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); 7553 sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
7556 out_unset_hw_params:
7557 iwl4965_unset_hw_params(priv);
7558 out_free_eeprom: 7554 out_free_eeprom:
7559 iwl_eeprom_free(priv); 7555 iwl_eeprom_free(priv);
7560 out_iounmap: 7556 out_iounmap:
@@ -7618,7 +7614,6 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev)
7618 iwl4965_rx_queue_free(priv, &priv->rxq); 7614 iwl4965_rx_queue_free(priv, &priv->rxq);
7619 iwl4965_hw_txq_ctx_free(priv); 7615 iwl4965_hw_txq_ctx_free(priv);
7620 7616
7621 iwl4965_unset_hw_params(priv);
7622 iwlcore_clear_stations_table(priv); 7617 iwlcore_clear_stations_table(priv);
7623 iwl_eeprom_free(priv); 7618 iwl_eeprom_free(priv);
7624 7619