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

scsi: qla4xxx: Use zeroing allocator rather than allocator/memset

Use dma_zalloc_coherent instead of dma_alloc_coherent followed by memset
0.

Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Suggested-by: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Himanshu Jha and committed by
Martin K. Petersen
d103adb3 bef4e688

+18 -25
+2 -3
drivers/scsi/qla4xxx/ql4_init.c
··· 153 153 dma_addr_t sys_info_dma; 154 154 int status = QLA_ERROR; 155 155 156 - sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), 157 - &sys_info_dma, GFP_KERNEL); 156 + sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), 157 + &sys_info_dma, GFP_KERNEL); 158 158 if (sys_info == NULL) { 159 159 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", 160 160 ha->host_no, __func__)); 161 161 162 162 goto exit_get_sys_info_no_free; 163 163 } 164 - memset(sys_info, 0, sizeof(*sys_info)); 165 164 166 165 /* Get flash sys info */ 167 166 if (qla4xxx_get_flash(ha, sys_info_dma, FLASH_OFFSET_SYS_INFO,
+9 -12
drivers/scsi/qla4xxx/ql4_mbx.c
··· 625 625 uint32_t mbox_sts[MBOX_REG_COUNT]; 626 626 int status = QLA_ERROR; 627 627 628 - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, 629 - sizeof(struct addr_ctrl_blk), 630 - &init_fw_cb_dma, GFP_KERNEL); 628 + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, 629 + sizeof(struct addr_ctrl_blk), 630 + &init_fw_cb_dma, GFP_KERNEL); 631 631 if (init_fw_cb == NULL) { 632 632 DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", 633 633 ha->host_no, __func__)); 634 634 goto exit_init_fw_cb_no_free; 635 635 } 636 - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); 637 636 638 637 /* Get Initialize Firmware Control Block. */ 639 638 memset(&mbox_cmd, 0, sizeof(mbox_cmd)); ··· 709 710 uint32_t mbox_cmd[MBOX_REG_COUNT]; 710 711 uint32_t mbox_sts[MBOX_REG_COUNT]; 711 712 712 - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, 713 - sizeof(struct addr_ctrl_blk), 714 - &init_fw_cb_dma, GFP_KERNEL); 713 + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, 714 + sizeof(struct addr_ctrl_blk), 715 + &init_fw_cb_dma, GFP_KERNEL); 715 716 if (init_fw_cb == NULL) { 716 717 printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, 717 718 __func__); ··· 719 720 } 720 721 721 722 /* Get Initialize Firmware Control Block. */ 722 - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); 723 723 if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != 724 724 QLA_SUCCESS) { 725 725 DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", ··· 1340 1342 uint32_t mbox_sts[MBOX_REG_COUNT]; 1341 1343 int status = QLA_ERROR; 1342 1344 1343 - about_fw = dma_alloc_coherent(&ha->pdev->dev, 1344 - sizeof(struct about_fw_info), 1345 - &about_fw_dma, GFP_KERNEL); 1345 + about_fw = dma_zalloc_coherent(&ha->pdev->dev, 1346 + sizeof(struct about_fw_info), 1347 + &about_fw_dma, GFP_KERNEL); 1346 1348 if (!about_fw) { 1347 1349 DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory " 1348 1350 "for about_fw\n", __func__)); 1349 1351 return status; 1350 1352 } 1351 1353 1352 - memset(about_fw, 0, sizeof(struct about_fw_info)); 1353 1354 memset(&mbox_cmd, 0, sizeof(mbox_cmd)); 1354 1355 memset(&mbox_sts, 0, sizeof(mbox_sts)); 1355 1356
+2 -3
drivers/scsi/qla4xxx/ql4_nx.c
··· 4050 4050 dma_addr_t sys_info_dma; 4051 4051 int status = QLA_ERROR; 4052 4052 4053 - sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), 4054 - &sys_info_dma, GFP_KERNEL); 4053 + sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), 4054 + &sys_info_dma, GFP_KERNEL); 4055 4055 if (sys_info == NULL) { 4056 4056 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", 4057 4057 ha->host_no, __func__)); 4058 4058 return status; 4059 4059 } 4060 4060 4061 - memset(sys_info, 0, sizeof(*sys_info)); 4062 4061 memset(&mbox_cmd, 0, sizeof(mbox_cmd)); 4063 4062 memset(&mbox_sts, 0, sizeof(mbox_sts)); 4064 4063
+5 -7
drivers/scsi/qla4xxx/ql4_os.c
··· 2689 2689 uint32_t rem = len; 2690 2690 struct nlattr *attr; 2691 2691 2692 - init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, 2693 - sizeof(struct addr_ctrl_blk), 2694 - &init_fw_cb_dma, GFP_KERNEL); 2692 + init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, 2693 + sizeof(struct addr_ctrl_blk), 2694 + &init_fw_cb_dma, GFP_KERNEL); 2695 2695 if (!init_fw_cb) { 2696 2696 ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", 2697 2697 __func__); 2698 2698 return -ENOMEM; 2699 2699 } 2700 2700 2701 - memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); 2702 2701 memset(&mbox_cmd, 0, sizeof(mbox_cmd)); 2703 2702 memset(&mbox_sts, 0, sizeof(mbox_sts)); 2704 2703 ··· 4195 4196 sizeof(struct shadow_regs) + 4196 4197 MEM_ALIGN_VALUE + 4197 4198 (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); 4198 - ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len, 4199 - &ha->queues_dma, GFP_KERNEL); 4199 + ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len, 4200 + &ha->queues_dma, GFP_KERNEL); 4200 4201 if (ha->queues == NULL) { 4201 4202 ql4_printk(KERN_WARNING, ha, 4202 4203 "Memory Allocation failed - queues.\n"); 4203 4204 4204 4205 goto mem_alloc_error_exit; 4205 4206 } 4206 - memset(ha->queues, 0, ha->queues_len); 4207 4207 4208 4208 /* 4209 4209 * As per RISC alignment requirements -- the bus-address must be a