aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl3945-base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c120
1 files changed, 56 insertions, 64 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 76186f85c131..4fa85d874efa 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -5767,6 +5767,12 @@ static void iwl3945_nic_start(struct iwl3945_priv *priv)
5767 iwl3945_write32(priv, CSR_RESET, 0); 5767 iwl3945_write32(priv, CSR_RESET, 0);
5768} 5768}
5769 5769
5770static int iwl3945_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
5771{
5772 desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr);
5773 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
5774}
5775
5770/** 5776/**
5771 * iwl3945_read_ucode - Read uCode images from disk file. 5777 * iwl3945_read_ucode - Read uCode images from disk file.
5772 * 5778 *
@@ -5775,7 +5781,7 @@ static void iwl3945_nic_start(struct iwl3945_priv *priv)
5775static int iwl3945_read_ucode(struct iwl3945_priv *priv) 5781static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5776{ 5782{
5777 struct iwl3945_ucode *ucode; 5783 struct iwl3945_ucode *ucode;
5778 int rc = 0; 5784 int ret = 0;
5779 const struct firmware *ucode_raw; 5785 const struct firmware *ucode_raw;
5780 /* firmware file name contains uCode/driver compatibility version */ 5786 /* firmware file name contains uCode/driver compatibility version */
5781 const char *name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode"; 5787 const char *name = "iwlwifi-3945" IWL3945_UCODE_API ".ucode";
@@ -5785,9 +5791,10 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5785 5791
5786 /* Ask kernel firmware_class module to get the boot firmware off disk. 5792 /* Ask kernel firmware_class module to get the boot firmware off disk.
5787 * request_firmware() is synchronous, file is in memory on return. */ 5793 * request_firmware() is synchronous, file is in memory on return. */
5788 rc = request_firmware(&ucode_raw, name, &priv->pci_dev->dev); 5794 ret = request_firmware(&ucode_raw, name, &priv->pci_dev->dev);
5789 if (rc < 0) { 5795 if (ret < 0) {
5790 IWL_ERROR("%s firmware file req failed: Reason %d\n", name, rc); 5796 IWL_ERROR("%s firmware file req failed: Reason %d\n",
5797 name, ret);
5791 goto error; 5798 goto error;
5792 } 5799 }
5793 5800
@@ -5797,7 +5804,7 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5797 /* Make sure that we got at least our header! */ 5804 /* Make sure that we got at least our header! */
5798 if (ucode_raw->size < sizeof(*ucode)) { 5805 if (ucode_raw->size < sizeof(*ucode)) {
5799 IWL_ERROR("File size way too small!\n"); 5806 IWL_ERROR("File size way too small!\n");
5800 rc = -EINVAL; 5807 ret = -EINVAL;
5801 goto err_release; 5808 goto err_release;
5802 } 5809 }
5803 5810
@@ -5825,43 +5832,40 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5825 5832
5826 IWL_DEBUG_INFO("uCode file size %d too small\n", 5833 IWL_DEBUG_INFO("uCode file size %d too small\n",
5827 (int)ucode_raw->size); 5834 (int)ucode_raw->size);
5828 rc = -EINVAL; 5835 ret = -EINVAL;
5829 goto err_release; 5836 goto err_release;
5830 } 5837 }
5831 5838
5832 /* Verify that uCode images will fit in card's SRAM */ 5839 /* Verify that uCode images will fit in card's SRAM */
5833 if (inst_size > IWL_MAX_INST_SIZE) { 5840 if (inst_size > IWL_MAX_INST_SIZE) {
5834 IWL_DEBUG_INFO("uCode instr len %d too large to fit in card\n", 5841 IWL_DEBUG_INFO("uCode instr len %d too large to fit in\n",
5835 (int)inst_size); 5842 inst_size);
5836 rc = -EINVAL; 5843 ret = -EINVAL;
5837 goto err_release; 5844 goto err_release;
5838 } 5845 }
5839 5846
5840 if (data_size > IWL_MAX_DATA_SIZE) { 5847 if (data_size > IWL_MAX_DATA_SIZE) {
5841 IWL_DEBUG_INFO("uCode data len %d too large to fit in card\n", 5848 IWL_DEBUG_INFO("uCode data len %d too large to fit in\n",
5842 (int)data_size); 5849 data_size);
5843 rc = -EINVAL; 5850 ret = -EINVAL;
5844 goto err_release; 5851 goto err_release;
5845 } 5852 }
5846 if (init_size > IWL_MAX_INST_SIZE) { 5853 if (init_size > IWL_MAX_INST_SIZE) {
5847 IWL_DEBUG_INFO 5854 IWL_DEBUG_INFO("uCode init instr len %d too large to fit in\n",
5848 ("uCode init instr len %d too large to fit in card\n", 5855 init_size);
5849 (int)init_size); 5856 ret = -EINVAL;
5850 rc = -EINVAL;
5851 goto err_release; 5857 goto err_release;
5852 } 5858 }
5853 if (init_data_size > IWL_MAX_DATA_SIZE) { 5859 if (init_data_size > IWL_MAX_DATA_SIZE) {
5854 IWL_DEBUG_INFO 5860 IWL_DEBUG_INFO("uCode init data len %d too large to fit in\n",
5855 ("uCode init data len %d too large to fit in card\n", 5861 init_data_size);
5856 (int)init_data_size); 5862 ret = -EINVAL;
5857 rc = -EINVAL;
5858 goto err_release; 5863 goto err_release;
5859 } 5864 }
5860 if (boot_size > IWL_MAX_BSM_SIZE) { 5865 if (boot_size > IWL_MAX_BSM_SIZE) {
5861 IWL_DEBUG_INFO 5866 IWL_DEBUG_INFO("uCode boot instr len %d too large to fit in\n",
5862 ("uCode boot instr len %d too large to fit in bsm\n", 5867 boot_size);
5863 (int)boot_size); 5868 ret = -EINVAL;
5864 rc = -EINVAL;
5865 goto err_release; 5869 goto err_release;
5866 } 5870 }
5867 5871
@@ -5871,56 +5875,45 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5871 * 1) unmodified from disk 5875 * 1) unmodified from disk
5872 * 2) backup cache for save/restore during power-downs */ 5876 * 2) backup cache for save/restore during power-downs */
5873 priv->ucode_code.len = inst_size; 5877 priv->ucode_code.len = inst_size;
5874 priv->ucode_code.v_addr = 5878 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_code);
5875 pci_alloc_consistent(priv->pci_dev,
5876 priv->ucode_code.len,
5877 &(priv->ucode_code.p_addr));
5878 5879
5879 priv->ucode_data.len = data_size; 5880 priv->ucode_data.len = data_size;
5880 priv->ucode_data.v_addr = 5881 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_data);
5881 pci_alloc_consistent(priv->pci_dev,
5882 priv->ucode_data.len,
5883 &(priv->ucode_data.p_addr));
5884 5882
5885 priv->ucode_data_backup.len = data_size; 5883 priv->ucode_data_backup.len = data_size;
5886 priv->ucode_data_backup.v_addr = 5884 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup);
5887 pci_alloc_consistent(priv->pci_dev,
5888 priv->ucode_data_backup.len,
5889 &(priv->ucode_data_backup.p_addr));
5890 5885
5886 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr ||
5887 !priv->ucode_data_backup.v_addr)
5888 goto err_pci_alloc;
5891 5889
5892 /* Initialization instructions and data */ 5890 /* Initialization instructions and data */
5893 priv->ucode_init.len = init_size; 5891 if (init_size && init_data_size) {
5894 priv->ucode_init.v_addr = 5892 priv->ucode_init.len = init_size;
5895 pci_alloc_consistent(priv->pci_dev, 5893 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_init);
5896 priv->ucode_init.len, 5894
5897 &(priv->ucode_init.p_addr)); 5895 priv->ucode_init_data.len = init_data_size;
5898 5896 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data);
5899 priv->ucode_init_data.len = init_data_size; 5897
5900 priv->ucode_init_data.v_addr = 5898 if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr)
5901 pci_alloc_consistent(priv->pci_dev, 5899 goto err_pci_alloc;
5902 priv->ucode_init_data.len, 5900 }
5903 &(priv->ucode_init_data.p_addr));
5904 5901
5905 /* Bootstrap (instructions only, no data) */ 5902 /* Bootstrap (instructions only, no data) */
5906 priv->ucode_boot.len = boot_size; 5903 if (boot_size) {
5907 priv->ucode_boot.v_addr = 5904 priv->ucode_boot.len = boot_size;
5908 pci_alloc_consistent(priv->pci_dev, 5905 iwl3945_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot);
5909 priv->ucode_boot.len,
5910 &(priv->ucode_boot.p_addr));
5911 5906
5912 if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || 5907 if (!priv->ucode_boot.v_addr)
5913 !priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr || 5908 goto err_pci_alloc;
5914 !priv->ucode_boot.v_addr || !priv->ucode_data_backup.v_addr) 5909 }
5915 goto err_pci_alloc;
5916 5910
5917 /* Copy images into buffers for card's bus-master reads ... */ 5911 /* Copy images into buffers for card's bus-master reads ... */
5918 5912
5919 /* Runtime instructions (first block of data in file) */ 5913 /* Runtime instructions (first block of data in file) */
5920 src = &ucode->data[0]; 5914 src = &ucode->data[0];
5921 len = priv->ucode_code.len; 5915 len = priv->ucode_code.len;
5922 IWL_DEBUG_INFO("Copying (but not loading) uCode instr len %d\n", 5916 IWL_DEBUG_INFO("Copying (but not loading) uCode instr len %Zd\n", len);
5923 (int)len);
5924 memcpy(priv->ucode_code.v_addr, src, len); 5917 memcpy(priv->ucode_code.v_addr, src, len);
5925 IWL_DEBUG_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", 5918 IWL_DEBUG_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
5926 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 5919 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
@@ -5929,8 +5922,7 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5929 * NOTE: Copy into backup buffer will be done in iwl3945_up() */ 5922 * NOTE: Copy into backup buffer will be done in iwl3945_up() */
5930 src = &ucode->data[inst_size]; 5923 src = &ucode->data[inst_size];
5931 len = priv->ucode_data.len; 5924 len = priv->ucode_data.len;
5932 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %d\n", 5925 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %Zd\n", len);
5933 (int)len);
5934 memcpy(priv->ucode_data.v_addr, src, len); 5926 memcpy(priv->ucode_data.v_addr, src, len);
5935 memcpy(priv->ucode_data_backup.v_addr, src, len); 5927 memcpy(priv->ucode_data_backup.v_addr, src, len);
5936 5928
@@ -5938,8 +5930,8 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5938 if (init_size) { 5930 if (init_size) {
5939 src = &ucode->data[inst_size + data_size]; 5931 src = &ucode->data[inst_size + data_size];
5940 len = priv->ucode_init.len; 5932 len = priv->ucode_init.len;
5941 IWL_DEBUG_INFO("Copying (but not loading) init instr len %d\n", 5933 IWL_DEBUG_INFO("Copying (but not loading) init instr len %Zd\n",
5942 (int)len); 5934 len);
5943 memcpy(priv->ucode_init.v_addr, src, len); 5935 memcpy(priv->ucode_init.v_addr, src, len);
5944 } 5936 }
5945 5937
@@ -5965,14 +5957,14 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
5965 5957
5966 err_pci_alloc: 5958 err_pci_alloc:
5967 IWL_ERROR("failed to allocate pci memory\n"); 5959 IWL_ERROR("failed to allocate pci memory\n");
5968 rc = -ENOMEM; 5960 ret = -ENOMEM;
5969 iwl3945_dealloc_ucode_pci(priv); 5961 iwl3945_dealloc_ucode_pci(priv);
5970 5962
5971 err_release: 5963 err_release:
5972 release_firmware(ucode_raw); 5964 release_firmware(ucode_raw);
5973 5965
5974 error: 5966 error:
5975 return rc; 5967 return ret;
5976} 5968}
5977 5969
5978 5970