aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-01-14 20:46:20 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:58 -0500
commit98c92211462bb78fe0e869b43e1662e549e35fed (patch)
tree0cfed83c186d801cb06e9d3aac4c7a3014e302f8 /drivers/net
parente655b9f03f41c7a84fb74d6619abf844d7f2ab65 (diff)
iwlwifi: move uCode helper functions to iwl-helpers.h
This patch adds iwl_free_fw_desc ucode helper function. It also moves ucode helper functions to iwl-helpers.h. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c66
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c65
3 files changed, 42 insertions, 107 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 5228834758b1..cd2eb1848310 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -257,4 +257,22 @@ static inline u8 iwl_get_dma_hi_address(dma_addr_t addr)
257 return sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0; 257 return sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0;
258} 258}
259 259
260/* TODO: Move fw_desc functions to iwl-pci.ko */
261static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
262 struct fw_desc *desc)
263{
264 if (desc->v_addr)
265 pci_free_consistent(pci_dev, desc->len,
266 desc->v_addr, desc->p_addr);
267 desc->v_addr = NULL;
268 desc->len = 0;
269}
270
271static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev,
272 struct fw_desc *desc)
273{
274 desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr);
275 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
276}
277
260#endif /* __iwl_helpers_h__ */ 278#endif /* __iwl_helpers_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index b9a74f5eea51..d886962392ef 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -5479,48 +5479,12 @@ static int iwl3945_init_geos(struct iwl3945_priv *priv)
5479 5479
5480static void iwl3945_dealloc_ucode_pci(struct iwl3945_priv *priv) 5480static void iwl3945_dealloc_ucode_pci(struct iwl3945_priv *priv)
5481{ 5481{
5482 if (priv->ucode_code.v_addr != NULL) { 5482 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code);
5483 pci_free_consistent(priv->pci_dev, 5483 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data);
5484 priv->ucode_code.len, 5484 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
5485 priv->ucode_code.v_addr, 5485 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init);
5486 priv->ucode_code.p_addr); 5486 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init_data);
5487 priv->ucode_code.v_addr = NULL; 5487 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_boot);
5488 }
5489 if (priv->ucode_data.v_addr != NULL) {
5490 pci_free_consistent(priv->pci_dev,
5491 priv->ucode_data.len,
5492 priv->ucode_data.v_addr,
5493 priv->ucode_data.p_addr);
5494 priv->ucode_data.v_addr = NULL;
5495 }
5496 if (priv->ucode_data_backup.v_addr != NULL) {
5497 pci_free_consistent(priv->pci_dev,
5498 priv->ucode_data_backup.len,
5499 priv->ucode_data_backup.v_addr,
5500 priv->ucode_data_backup.p_addr);
5501 priv->ucode_data_backup.v_addr = NULL;
5502 }
5503 if (priv->ucode_init.v_addr != NULL) {
5504 pci_free_consistent(priv->pci_dev,
5505 priv->ucode_init.len,
5506 priv->ucode_init.v_addr,
5507 priv->ucode_init.p_addr);
5508 priv->ucode_init.v_addr = NULL;
5509 }
5510 if (priv->ucode_init_data.v_addr != NULL) {
5511 pci_free_consistent(priv->pci_dev,
5512 priv->ucode_init_data.len,
5513 priv->ucode_init_data.v_addr,
5514 priv->ucode_init_data.p_addr);
5515 priv->ucode_init_data.v_addr = NULL;
5516 }
5517 if (priv->ucode_boot.v_addr != NULL) {
5518 pci_free_consistent(priv->pci_dev,
5519 priv->ucode_boot.len,
5520 priv->ucode_boot.v_addr,
5521 priv->ucode_boot.p_addr);
5522 priv->ucode_boot.v_addr = NULL;
5523 }
5524} 5488}
5525 5489
5526/** 5490/**
@@ -5817,12 +5781,6 @@ static void iwl3945_nic_start(struct iwl3945_priv *priv)
5817 iwl3945_write32(priv, CSR_RESET, 0); 5781 iwl3945_write32(priv, CSR_RESET, 0);
5818} 5782}
5819 5783
5820static int iwl3945_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
5821{
5822 desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr);
5823 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
5824}
5825
5826/** 5784/**
5827 * iwl3945_read_ucode - Read uCode images from disk file. 5785 * iwl3945_read_ucode - Read uCode images from disk file.
5828 * 5786 *
@@ -5925,13 +5883,13 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5925 * 1) unmodified from disk 5883 * 1) unmodified from disk
5926 * 2) backup cache for save/restore during power-downs */ 5884 * 2) backup cache for save/restore during power-downs */
5927 priv->ucode_code.len = inst_size; 5885 priv->ucode_code.len = inst_size;
5928 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); 5886 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
5929 5887
5930 priv->ucode_data.len = data_size; 5888 priv->ucode_data.len = data_size;
5931 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); 5889 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
5932 5890
5933 priv->ucode_data_backup.len = data_size; 5891 priv->ucode_data_backup.len = data_size;
5934 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); 5892 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
5935 5893
5936 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || 5894 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr ||
5937 !priv->ucode_data_backup.v_addr) 5895 !priv->ucode_data_backup.v_addr)
@@ -5940,10 +5898,10 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5940 /* Initialization instructions and data */ 5898 /* Initialization instructions and data */
5941 if (init_size && init_data_size) { 5899 if (init_size && init_data_size) {
5942 priv->ucode_init.len = init_size; 5900 priv->ucode_init.len = init_size;
5943 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); 5901 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
5944 5902
5945 priv->ucode_init_data.len = init_data_size; 5903 priv->ucode_init_data.len = init_data_size;
5946 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); 5904 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
5947 5905
5948 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) 5906 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
5949 goto err_pci_alloc; 5907 goto err_pci_alloc;
@@ -5952,7 +5910,7 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5952 /* Bootstrap (instructions only, no data) */ 5910 /* Bootstrap (instructions only, no data) */
5953 if (boot_size) { 5911 if (boot_size) {
5954 priv->ucode_boot.len = boot_size; 5912 priv->ucode_boot.len = boot_size;
5955 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); 5913 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
5956 5914
5957 if (!priv->ucode_boot.v_addr) 5915 if (!priv->ucode_boot.v_addr)
5958 goto err_pci_alloc; 5916 goto err_pci_alloc;
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index 811e41b7f664..6361fe8478aa 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -5917,48 +5917,12 @@ static int iwl4965_init_geos(struct iwl4965_priv *priv)
5917 5917
5918static void iwl4965_dealloc_ucode_pci(struct iwl4965_priv *priv) 5918static void iwl4965_dealloc_ucode_pci(struct iwl4965_priv *priv)
5919{ 5919{
5920 if (priv->ucode_code.v_addr != NULL) { 5920 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_code);
5921 pci_free_consistent(priv->pci_dev, 5921 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data);
5922 priv->ucode_code.len, 5922 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
5923 priv->ucode_code.v_addr, 5923 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init);
5924 priv->ucode_code.p_addr); 5924 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_init_data);
5925 priv->ucode_code.v_addr = NULL; 5925 iwl_free_fw_desc(priv->pci_dev, &priv->ucode_boot);
5926 }
5927 if (priv->ucode_data.v_addr != NULL) {
5928 pci_free_consistent(priv->pci_dev,
5929 priv->ucode_data.len,
5930 priv->ucode_data.v_addr,
5931 priv->ucode_data.p_addr);
5932 priv->ucode_data.v_addr = NULL;
5933 }
5934 if (priv->ucode_data_backup.v_addr != NULL) {
5935 pci_free_consistent(priv->pci_dev,
5936 priv->ucode_data_backup.len,
5937 priv->ucode_data_backup.v_addr,
5938 priv->ucode_data_backup.p_addr);
5939 priv->ucode_data_backup.v_addr = NULL;
5940 }
5941 if (priv->ucode_init.v_addr != NULL) {
5942 pci_free_consistent(priv->pci_dev,
5943 priv->ucode_init.len,
5944 priv->ucode_init.v_addr,
5945 priv->ucode_init.p_addr);
5946 priv->ucode_init.v_addr = NULL;
5947 }
5948 if (priv->ucode_init_data.v_addr != NULL) {
5949 pci_free_consistent(priv->pci_dev,
5950 priv->ucode_init_data.len,
5951 priv->ucode_init_data.v_addr,
5952 priv->ucode_init_data.p_addr);
5953 priv->ucode_init_data.v_addr = NULL;
5954 }
5955 if (priv->ucode_boot.v_addr != NULL) {
5956 pci_free_consistent(priv->pci_dev,
5957 priv->ucode_boot.len,
5958 priv->ucode_boot.v_addr,
5959 priv->ucode_boot.p_addr);
5960 priv->ucode_boot.v_addr = NULL;
5961 }
5962} 5926}
5963 5927
5964/** 5928/**
@@ -6257,11 +6221,6 @@ static void iwl4965_nic_start(struct iwl4965_priv *priv)
6257 iwl4965_write32(priv, CSR_RESET, 0); 6221 iwl4965_write32(priv, CSR_RESET, 0);
6258} 6222}
6259 6223
6260static int iwl4965_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
6261{
6262 desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr);
6263 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
6264}
6265 6224
6266/** 6225/**
6267 * iwl4965_read_ucode - Read uCode images from disk file. 6226 * iwl4965_read_ucode - Read uCode images from disk file.
@@ -6372,21 +6331,21 @@ static int iwl4965_read_ucode(struct iwl4965_priv *priv)
6372 * 1) unmodified from disk 6331 * 1) unmodified from disk
6373 * 2) backup cache for save/restore during power-downs */ 6332 * 2) backup cache for save/restore during power-downs */
6374 priv->ucode_code.len = inst_size; 6333 priv->ucode_code.len = inst_size;
6375 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); 6334 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
6376 6335
6377 priv->ucode_data.len = data_size; 6336 priv->ucode_data.len = data_size;
6378 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); 6337 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
6379 6338
6380 priv->ucode_data_backup.len = data_size; 6339 priv->ucode_data_backup.len = data_size;
6381 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); 6340 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
6382 6341
6383 /* Initialization instructions and data */ 6342 /* Initialization instructions and data */
6384 if (init_size && init_data_size) { 6343 if (init_size && init_data_size) {
6385 priv->ucode_init.len = init_size; 6344 priv->ucode_init.len = init_size;
6386 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); 6345 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
6387 6346
6388 priv->ucode_init_data.len = init_data_size; 6347 priv->ucode_init_data.len = init_data_size;
6389 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); 6348 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
6390 6349
6391 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) 6350 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
6392 goto err_pci_alloc; 6351 goto err_pci_alloc;
@@ -6395,7 +6354,7 @@ static int iwl4965_read_ucode(struct iwl4965_priv *priv)
6395 /* Bootstrap (instructions only, no data) */ 6354 /* Bootstrap (instructions only, no data) */
6396 if (boot_size) { 6355 if (boot_size) {
6397 priv->ucode_boot.len = boot_size; 6356 priv->ucode_boot.len = boot_size;
6398 iwl4965_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); 6357 iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
6399 6358
6400 if (!priv->ucode_boot.v_addr) 6359 if (!priv->ucode_boot.v_addr)
6401 goto err_pci_alloc; 6360 goto err_pci_alloc;