diff options
author | Himanshu Jha <himanshujha199640@gmail.com> | 2017-12-30 10:28:24 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-01-04 01:07:58 -0500 |
commit | d103adb30049e293348ba6c71f5bc6636ffbeaef (patch) | |
tree | 59e36be40d0f9d1f3b7de9e98a06028669bbdfeb | |
parent | bef4e68830a102142fc4cb0c0ad4f1877d2ee557 (diff) |
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>
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_init.c | 5 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_mbx.c | 21 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_nx.c | 5 | ||||
-rw-r--r-- | drivers/scsi/qla4xxx/ql4_os.c | 12 |
4 files changed, 18 insertions, 25 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c index 5d6d158bbfd6..52b1a0bc93c9 100644 --- a/drivers/scsi/qla4xxx/ql4_init.c +++ b/drivers/scsi/qla4xxx/ql4_init.c | |||
@@ -153,15 +153,14 @@ int qla4xxx_get_sys_info(struct scsi_qla_host *ha) | |||
153 | dma_addr_t sys_info_dma; | 153 | dma_addr_t sys_info_dma; |
154 | int status = QLA_ERROR; | 154 | int status = QLA_ERROR; |
155 | 155 | ||
156 | sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), | 156 | sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), |
157 | &sys_info_dma, GFP_KERNEL); | 157 | &sys_info_dma, GFP_KERNEL); |
158 | if (sys_info == NULL) { | 158 | if (sys_info == NULL) { |
159 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", | 159 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
160 | ha->host_no, __func__)); | 160 | ha->host_no, __func__)); |
161 | 161 | ||
162 | goto exit_get_sys_info_no_free; | 162 | goto exit_get_sys_info_no_free; |
163 | } | 163 | } |
164 | memset(sys_info, 0, sizeof(*sys_info)); | ||
165 | 164 | ||
166 | /* Get flash sys info */ | 165 | /* Get flash sys info */ |
167 | if (qla4xxx_get_flash(ha, sys_info_dma, FLASH_OFFSET_SYS_INFO, | 166 | if (qla4xxx_get_flash(ha, sys_info_dma, FLASH_OFFSET_SYS_INFO, |
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index 1da04f323d38..bda2e64ee5ca 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c | |||
@@ -625,15 +625,14 @@ int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha) | |||
625 | uint32_t mbox_sts[MBOX_REG_COUNT]; | 625 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
626 | int status = QLA_ERROR; | 626 | int status = QLA_ERROR; |
627 | 627 | ||
628 | init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, | 628 | init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, |
629 | sizeof(struct addr_ctrl_blk), | 629 | sizeof(struct addr_ctrl_blk), |
630 | &init_fw_cb_dma, GFP_KERNEL); | 630 | &init_fw_cb_dma, GFP_KERNEL); |
631 | if (init_fw_cb == NULL) { | 631 | if (init_fw_cb == NULL) { |
632 | DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", | 632 | DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n", |
633 | ha->host_no, __func__)); | 633 | ha->host_no, __func__)); |
634 | goto exit_init_fw_cb_no_free; | 634 | goto exit_init_fw_cb_no_free; |
635 | } | 635 | } |
636 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); | ||
637 | 636 | ||
638 | /* Get Initialize Firmware Control Block. */ | 637 | /* Get Initialize Firmware Control Block. */ |
639 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); | 638 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
@@ -710,9 +709,9 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) | |||
710 | uint32_t mbox_cmd[MBOX_REG_COUNT]; | 709 | uint32_t mbox_cmd[MBOX_REG_COUNT]; |
711 | uint32_t mbox_sts[MBOX_REG_COUNT]; | 710 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
712 | 711 | ||
713 | init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, | 712 | init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, |
714 | sizeof(struct addr_ctrl_blk), | 713 | sizeof(struct addr_ctrl_blk), |
715 | &init_fw_cb_dma, GFP_KERNEL); | 714 | &init_fw_cb_dma, GFP_KERNEL); |
716 | if (init_fw_cb == NULL) { | 715 | if (init_fw_cb == NULL) { |
717 | printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, | 716 | printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no, |
718 | __func__); | 717 | __func__); |
@@ -720,7 +719,6 @@ int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha) | |||
720 | } | 719 | } |
721 | 720 | ||
722 | /* Get Initialize Firmware Control Block. */ | 721 | /* Get Initialize Firmware Control Block. */ |
723 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); | ||
724 | if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != | 722 | if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma) != |
725 | QLA_SUCCESS) { | 723 | QLA_SUCCESS) { |
726 | DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", | 724 | DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n", |
@@ -1342,16 +1340,15 @@ int qla4xxx_about_firmware(struct scsi_qla_host *ha) | |||
1342 | uint32_t mbox_sts[MBOX_REG_COUNT]; | 1340 | uint32_t mbox_sts[MBOX_REG_COUNT]; |
1343 | int status = QLA_ERROR; | 1341 | int status = QLA_ERROR; |
1344 | 1342 | ||
1345 | about_fw = dma_alloc_coherent(&ha->pdev->dev, | 1343 | about_fw = dma_zalloc_coherent(&ha->pdev->dev, |
1346 | sizeof(struct about_fw_info), | 1344 | sizeof(struct about_fw_info), |
1347 | &about_fw_dma, GFP_KERNEL); | 1345 | &about_fw_dma, GFP_KERNEL); |
1348 | if (!about_fw) { | 1346 | if (!about_fw) { |
1349 | DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory " | 1347 | DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Unable to alloc memory " |
1350 | "for about_fw\n", __func__)); | 1348 | "for about_fw\n", __func__)); |
1351 | return status; | 1349 | return status; |
1352 | } | 1350 | } |
1353 | 1351 | ||
1354 | memset(about_fw, 0, sizeof(struct about_fw_info)); | ||
1355 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); | 1352 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
1356 | memset(&mbox_sts, 0, sizeof(mbox_sts)); | 1353 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
1357 | 1354 | ||
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index e91abb327745..968bd85610f8 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c | |||
@@ -4050,15 +4050,14 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha) | |||
4050 | dma_addr_t sys_info_dma; | 4050 | dma_addr_t sys_info_dma; |
4051 | int status = QLA_ERROR; | 4051 | int status = QLA_ERROR; |
4052 | 4052 | ||
4053 | sys_info = dma_alloc_coherent(&ha->pdev->dev, sizeof(*sys_info), | 4053 | sys_info = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*sys_info), |
4054 | &sys_info_dma, GFP_KERNEL); | 4054 | &sys_info_dma, GFP_KERNEL); |
4055 | if (sys_info == NULL) { | 4055 | if (sys_info == NULL) { |
4056 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", | 4056 | DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", |
4057 | ha->host_no, __func__)); | 4057 | ha->host_no, __func__)); |
4058 | return status; | 4058 | return status; |
4059 | } | 4059 | } |
4060 | 4060 | ||
4061 | memset(sys_info, 0, sizeof(*sys_info)); | ||
4062 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); | 4061 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
4063 | memset(&mbox_sts, 0, sizeof(mbox_sts)); | 4062 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
4064 | 4063 | ||
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 2b8a8ce2a431..82e889bbe0ed 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -2689,16 +2689,15 @@ qla4xxx_iface_set_param(struct Scsi_Host *shost, void *data, uint32_t len) | |||
2689 | uint32_t rem = len; | 2689 | uint32_t rem = len; |
2690 | struct nlattr *attr; | 2690 | struct nlattr *attr; |
2691 | 2691 | ||
2692 | init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, | 2692 | init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, |
2693 | sizeof(struct addr_ctrl_blk), | 2693 | sizeof(struct addr_ctrl_blk), |
2694 | &init_fw_cb_dma, GFP_KERNEL); | 2694 | &init_fw_cb_dma, GFP_KERNEL); |
2695 | if (!init_fw_cb) { | 2695 | if (!init_fw_cb) { |
2696 | ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", | 2696 | ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", |
2697 | __func__); | 2697 | __func__); |
2698 | return -ENOMEM; | 2698 | return -ENOMEM; |
2699 | } | 2699 | } |
2700 | 2700 | ||
2701 | memset(init_fw_cb, 0, sizeof(struct addr_ctrl_blk)); | ||
2702 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); | 2701 | memset(&mbox_cmd, 0, sizeof(mbox_cmd)); |
2703 | memset(&mbox_sts, 0, sizeof(mbox_sts)); | 2702 | memset(&mbox_sts, 0, sizeof(mbox_sts)); |
2704 | 2703 | ||
@@ -4196,15 +4195,14 @@ static int qla4xxx_mem_alloc(struct scsi_qla_host *ha) | |||
4196 | sizeof(struct shadow_regs) + | 4195 | sizeof(struct shadow_regs) + |
4197 | MEM_ALIGN_VALUE + | 4196 | MEM_ALIGN_VALUE + |
4198 | (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); | 4197 | (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); |
4199 | ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len, | 4198 | ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len, |
4200 | &ha->queues_dma, GFP_KERNEL); | 4199 | &ha->queues_dma, GFP_KERNEL); |
4201 | if (ha->queues == NULL) { | 4200 | if (ha->queues == NULL) { |
4202 | ql4_printk(KERN_WARNING, ha, | 4201 | ql4_printk(KERN_WARNING, ha, |
4203 | "Memory Allocation failed - queues.\n"); | 4202 | "Memory Allocation failed - queues.\n"); |
4204 | 4203 | ||
4205 | goto mem_alloc_error_exit; | 4204 | goto mem_alloc_error_exit; |
4206 | } | 4205 | } |
4207 | memset(ha->queues, 0, ha->queues_len); | ||
4208 | 4206 | ||
4209 | /* | 4207 | /* |
4210 | * As per RISC alignment requirements -- the bus-address must be a | 4208 | * As per RISC alignment requirements -- the bus-address must be a |