Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: use pci_zalloc_consistent

Remove the now unnecessary memset too.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Adam Radford <linuxraid@lsi.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Jayamohan Kallickal <jayamohan.kallickal@emulex.com>
Cc: Dario Ballabio <ballabio_dario@emc.com>
Cc: Michael Neuffer <mike@i-Connect.Net>
Cc: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
Cc: Neela Syam Kolli <megaraidlinux@lsi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
7c845eb5 8ac41b9d

+32 -59
+2 -3
drivers/scsi/3w-sas.c
··· 683 683 unsigned long *cpu_addr; 684 684 int retval = 1; 685 685 686 - cpu_addr = pci_alloc_consistent(tw_dev->tw_pci_dev, size*TW_Q_LENGTH, &dma_handle); 686 + cpu_addr = pci_zalloc_consistent(tw_dev->tw_pci_dev, size * TW_Q_LENGTH, 687 + &dma_handle); 687 688 if (!cpu_addr) { 688 689 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x5, "Memory allocation failed"); 689 690 goto out; 690 691 } 691 - 692 - memset(cpu_addr, 0, size*TW_Q_LENGTH); 693 692 694 693 for (i = 0; i < TW_Q_LENGTH; i++) { 695 694 switch(which) {
+2 -6
drivers/scsi/a100u2w.c
··· 1125 1125 1126 1126 /* Get total memory needed for SCB */ 1127 1127 sz = ORC_MAXQUEUE * sizeof(struct orc_scb); 1128 - host->scb_virt = pci_alloc_consistent(pdev, sz, 1129 - &host->scb_phys); 1128 + host->scb_virt = pci_zalloc_consistent(pdev, sz, &host->scb_phys); 1130 1129 if (!host->scb_virt) { 1131 1130 printk("inia100: SCB memory allocation error\n"); 1132 1131 goto out_host_put; 1133 1132 } 1134 - memset(host->scb_virt, 0, sz); 1135 1133 1136 1134 /* Get total memory needed for ESCB */ 1137 1135 sz = ORC_MAXQUEUE * sizeof(struct orc_extended_scb); 1138 - host->escb_virt = pci_alloc_consistent(pdev, sz, 1139 - &host->escb_phys); 1136 + host->escb_virt = pci_zalloc_consistent(pdev, sz, &host->escb_phys); 1140 1137 if (!host->escb_virt) { 1141 1138 printk("inia100: ESCB memory allocation error\n"); 1142 1139 goto out_free_scb_array; 1143 1140 } 1144 - memset(host->escb_virt, 0, sz); 1145 1141 1146 1142 biosaddr = host->BIOScfg; 1147 1143 biosaddr = (biosaddr << 4);
+4 -6
drivers/scsi/be2iscsi/be_main.c
··· 3538 3538 q->len = len; 3539 3539 q->entry_size = entry_size; 3540 3540 mem->size = len * entry_size; 3541 - mem->va = pci_alloc_consistent(phba->pcidev, mem->size, &mem->dma); 3541 + mem->va = pci_zalloc_consistent(phba->pcidev, mem->size, &mem->dma); 3542 3542 if (!mem->va) 3543 3543 return -ENOMEM; 3544 - memset(mem->va, 0, mem->size); 3545 3544 return 0; 3546 3545 } 3547 3546 ··· 4319 4320 "BM_%d : No boot session\n"); 4320 4321 return ret; 4321 4322 } 4322 - nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 4323 - sizeof(*session_resp), 4324 - &nonemb_cmd.dma); 4323 + nonemb_cmd.va = pci_zalloc_consistent(phba->ctrl.pdev, 4324 + sizeof(*session_resp), 4325 + &nonemb_cmd.dma); 4325 4326 if (nonemb_cmd.va == NULL) { 4326 4327 beiscsi_log(phba, KERN_ERR, 4327 4328 BEISCSI_LOG_INIT | BEISCSI_LOG_CONFIG, ··· 4331 4332 return -ENOMEM; 4332 4333 } 4333 4334 4334 - memset(nonemb_cmd.va, 0, sizeof(*session_resp)); 4335 4335 tag = mgmt_get_session_info(phba, s_handle, 4336 4336 &nonemb_cmd); 4337 4337 if (!tag) {
+1 -2
drivers/scsi/be2iscsi/be_mgmt.c
··· 900 900 static int mgmt_alloc_cmd_data(struct beiscsi_hba *phba, struct be_dma_mem *cmd, 901 901 int iscsi_cmd, int size) 902 902 { 903 - cmd->va = pci_alloc_consistent(phba->ctrl.pdev, size, &cmd->dma); 903 + cmd->va = pci_zalloc_consistent(phba->ctrl.pdev, size, &cmd->dma); 904 904 if (!cmd->va) { 905 905 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, 906 906 "BG_%d : Failed to allocate memory for if info\n"); 907 907 return -ENOMEM; 908 908 } 909 - memset(cmd->va, 0, size); 910 909 cmd->size = size; 911 910 be_cmd_hdr_prepare(cmd->va, CMD_SUBSYSTEM_ISCSI, iscsi_cmd, size); 912 911 return 0;
+1 -7
drivers/scsi/csiostor/csio_wr.c
··· 232 232 233 233 q = wrm->q_arr[free_idx]; 234 234 235 - q->vstart = pci_alloc_consistent(hw->pdev, qsz, &q->pstart); 235 + q->vstart = pci_zalloc_consistent(hw->pdev, qsz, &q->pstart); 236 236 if (!q->vstart) { 237 237 csio_err(hw, 238 238 "Failed to allocate DMA memory for " 239 239 "queue at id: %d size: %d\n", free_idx, qsize); 240 240 return -1; 241 241 } 242 - 243 - /* 244 - * We need to zero out the contents, importantly for ingress, 245 - * since we start with a generatiom bit of 1 for ingress. 246 - */ 247 - memset(q->vstart, 0, qsz); 248 242 249 243 q->type = type; 250 244 q->owner = owner;
+2 -3
drivers/scsi/eata.c
··· 1238 1238 struct eata_config *cf; 1239 1239 dma_addr_t cf_dma_addr; 1240 1240 1241 - cf = pci_alloc_consistent(pdev, sizeof(struct eata_config), 1242 - &cf_dma_addr); 1241 + cf = pci_zalloc_consistent(pdev, sizeof(struct eata_config), 1242 + &cf_dma_addr); 1243 1243 1244 1244 if (!cf) { 1245 1245 printk ··· 1249 1249 } 1250 1250 1251 1251 /* Set board configuration */ 1252 - memset((char *)cf, 0, sizeof(struct eata_config)); 1253 1252 cf->len = (ushort) H2DEV16((ushort) 510); 1254 1253 cf->ocena = 1; 1255 1254
+3 -5
drivers/scsi/hpsa.c
··· 4732 4732 union u64bit temp64; 4733 4733 dma_addr_t cmd_dma_handle, err_dma_handle; 4734 4734 4735 - c = pci_alloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle); 4735 + c = pci_zalloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle); 4736 4736 if (c == NULL) 4737 4737 return NULL; 4738 - memset(c, 0, sizeof(*c)); 4739 4738 4740 4739 c->cmd_type = CMD_SCSI; 4741 4740 c->cmdindex = -1; 4742 4741 4743 - c->err_info = pci_alloc_consistent(h->pdev, sizeof(*c->err_info), 4744 - &err_dma_handle); 4742 + c->err_info = pci_zalloc_consistent(h->pdev, sizeof(*c->err_info), 4743 + &err_dma_handle); 4745 4744 4746 4745 if (c->err_info == NULL) { 4747 4746 pci_free_consistent(h->pdev, 4748 4747 sizeof(*c), c, cmd_dma_handle); 4749 4748 return NULL; 4750 4749 } 4751 - memset(c->err_info, 0, sizeof(*c->err_info)); 4752 4750 4753 4751 INIT_LIST_HEAD(&c->list); 4754 4752 c->busaddr = (u32) cmd_dma_handle;
+7 -9
drivers/scsi/megaraid/megaraid_mbox.c
··· 998 998 * Allocate the common 16-byte aligned memory for the handshake 999 999 * mailbox. 1000 1000 */ 1001 - raid_dev->una_mbox64 = pci_alloc_consistent(adapter->pdev, 1002 - sizeof(mbox64_t), &raid_dev->una_mbox64_dma); 1001 + raid_dev->una_mbox64 = pci_zalloc_consistent(adapter->pdev, 1002 + sizeof(mbox64_t), 1003 + &raid_dev->una_mbox64_dma); 1003 1004 1004 1005 if (!raid_dev->una_mbox64) { 1005 1006 con_log(CL_ANN, (KERN_WARNING ··· 1008 1007 __LINE__)); 1009 1008 return -1; 1010 1009 } 1011 - memset(raid_dev->una_mbox64, 0, sizeof(mbox64_t)); 1012 1010 1013 1011 /* 1014 1012 * Align the mailbox at 16-byte boundary ··· 1026 1026 align; 1027 1027 1028 1028 // Allocate memory for commands issued internally 1029 - adapter->ibuf = pci_alloc_consistent(pdev, MBOX_IBUF_SIZE, 1030 - &adapter->ibuf_dma_h); 1029 + adapter->ibuf = pci_zalloc_consistent(pdev, MBOX_IBUF_SIZE, 1030 + &adapter->ibuf_dma_h); 1031 1031 if (!adapter->ibuf) { 1032 1032 1033 1033 con_log(CL_ANN, (KERN_WARNING ··· 1036 1036 1037 1037 goto out_free_common_mbox; 1038 1038 } 1039 - memset(adapter->ibuf, 0, MBOX_IBUF_SIZE); 1040 1039 1041 1040 // Allocate memory for our SCSI Command Blocks and their associated 1042 1041 // memory ··· 2971 2972 * Issue an ENQUIRY3 command to find out certain adapter parameters, 2972 2973 * e.g., max channels, max commands etc. 2973 2974 */ 2974 - pinfo = pci_alloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t), 2975 - &pinfo_dma_h); 2975 + pinfo = pci_zalloc_consistent(adapter->pdev, sizeof(mraid_pinfo_t), 2976 + &pinfo_dma_h); 2976 2977 2977 2978 if (pinfo == NULL) { 2978 2979 con_log(CL_ANN, (KERN_WARNING ··· 2981 2982 2982 2983 return -1; 2983 2984 } 2984 - memset(pinfo, 0, sizeof(mraid_pinfo_t)); 2985 2985 2986 2986 mbox->xferaddr = (uint32_t)adapter->ibuf_dma_h; 2987 2987 memset((void *)adapter->ibuf, 0, MBOX_IBUF_SIZE);
+3 -5
drivers/scsi/megaraid/megaraid_sas_base.c
··· 2038 2038 2039 2039 if (initial) { 2040 2040 instance->hb_host_mem = 2041 - pci_alloc_consistent(instance->pdev, 2042 - sizeof(struct MR_CTRL_HB_HOST_MEM), 2043 - &instance->hb_host_mem_h); 2041 + pci_zalloc_consistent(instance->pdev, 2042 + sizeof(struct MR_CTRL_HB_HOST_MEM), 2043 + &instance->hb_host_mem_h); 2044 2044 if (!instance->hb_host_mem) { 2045 2045 printk(KERN_DEBUG "megasas: SR-IOV: Couldn't allocate" 2046 2046 " memory for heartbeat host memory for " ··· 2048 2048 retval = -ENOMEM; 2049 2049 goto out; 2050 2050 } 2051 - memset(instance->hb_host_mem, 0, 2052 - sizeof(struct MR_CTRL_HB_HOST_MEM)); 2053 2051 } 2054 2052 2055 2053 memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
+2 -4
drivers/scsi/mesh.c
··· 1915 1915 /* We use the PCI APIs for now until the generic one gets fixed 1916 1916 * enough or until we get some macio-specific versions 1917 1917 */ 1918 - dma_cmd_space = pci_alloc_consistent(macio_get_pci_dev(mdev), 1919 - ms->dma_cmd_size, 1920 - &dma_cmd_bus); 1918 + dma_cmd_space = pci_zalloc_consistent(macio_get_pci_dev(mdev), 1919 + ms->dma_cmd_size, &dma_cmd_bus); 1921 1920 if (dma_cmd_space == NULL) { 1922 1921 printk(KERN_ERR "mesh: can't allocate DMA table\n"); 1923 1922 goto out_unmap; 1924 1923 } 1925 - memset(dma_cmd_space, 0, ms->dma_cmd_size); 1926 1924 1927 1925 ms->dma_cmds = (struct dbdma_cmd *) DBDMA_ALIGN(dma_cmd_space); 1928 1926 ms->dma_cmd_space = dma_cmd_space;
+3 -6
drivers/scsi/mvumi.c
··· 142 142 143 143 case RESOURCE_UNCACHED_MEMORY: 144 144 size = round_up(size, 8); 145 - res->virt_addr = pci_alloc_consistent(mhba->pdev, size, 146 - &res->bus_addr); 145 + res->virt_addr = pci_zalloc_consistent(mhba->pdev, size, 146 + &res->bus_addr); 147 147 if (!res->virt_addr) { 148 148 dev_err(&mhba->pdev->dev, 149 149 "unable to allocate consistent mem," ··· 151 151 kfree(res); 152 152 return NULL; 153 153 } 154 - memset(res->virt_addr, 0, size); 155 154 break; 156 155 157 156 default: ··· 257 258 if (size == 0) 258 259 return 0; 259 260 260 - virt_addr = pci_alloc_consistent(mhba->pdev, size, &phy_addr); 261 + virt_addr = pci_zalloc_consistent(mhba->pdev, size, &phy_addr); 261 262 if (!virt_addr) 262 263 return -1; 263 - 264 - memset(virt_addr, 0, size); 265 264 266 265 m_sg = (struct mvumi_sgl *) &cmd->frame->payload[0]; 267 266 cmd->frame->sg_counts = 1;
+2 -3
drivers/scsi/pm8001/pm8001_sas.c
··· 116 116 u64 align_offset = 0; 117 117 if (align) 118 118 align_offset = (dma_addr_t)align - 1; 119 - mem_virt_alloc = 120 - pci_alloc_consistent(pdev, mem_size + align, &mem_dma_handle); 119 + mem_virt_alloc = pci_zalloc_consistent(pdev, mem_size + align, 120 + &mem_dma_handle); 121 121 if (!mem_virt_alloc) { 122 122 pm8001_printk("memory allocation error\n"); 123 123 return -1; 124 124 } 125 - memset((void *)mem_virt_alloc, 0, mem_size+align); 126 125 *pphys_addr = mem_dma_handle; 127 126 phys_align = (*pphys_addr + align_offset) & ~align_offset; 128 127 *virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr;