scsi: qla2xxx: Use zeroing allocator rather than allocator/memset
authorHimanshu Jha <himanshujha199640@gmail.com>
Sat, 30 Dec 2017 15:28:25 +0000 (20:58 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 4 Jan 2018 06:09:26 +0000 (01:09 -0500)
Use dma_zalloc_coherent and vzalloc instead of dma_alloc_coherent and
vmalloc respectively, 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: Himanshu Madhani <himanshu.madhani@cavium.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_bsg.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c

index b360df9936ffb0ef4ae48673775a5ce7f02a5ee4..89a4999fa631f213b52ac1ca15eacba2f9b48f93 100644 (file)
@@ -1843,14 +1843,13 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
        if (qla2x00_reset_active(vha))
                goto done;
 
-       stats = dma_alloc_coherent(&ha->pdev->dev,
-           sizeof(*stats), &stats_dma, GFP_KERNEL);
+       stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats),
+                                   &stats_dma, GFP_KERNEL);
        if (!stats) {
                ql_log(ql_log_warn, vha, 0x707d,
                    "Failed to allocate memory for stats.\n");
                goto done;
        }
-       memset(stats, 0, sizeof(*stats));
 
        rval = QLA_FUNCTION_FAILED;
        if (IS_FWI2_CAPABLE(ha)) {
index e3ac7078d2aaa722ce476c4d3595814437ccbfdc..e2d5d3ca0f57c57307b1cbf202f6e358f999801b 100644 (file)
@@ -1435,7 +1435,7 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha,
                ha->optrom_state = QLA_SREADING;
        }
 
-       ha->optrom_buffer = vmalloc(ha->optrom_region_size);
+       ha->optrom_buffer = vzalloc(ha->optrom_region_size);
        if (!ha->optrom_buffer) {
                ql_log(ql_log_warn, vha, 0x7059,
                    "Read: Unable to allocate memory for optrom retrieval "
@@ -1445,7 +1445,6 @@ qla2x00_optrom_setup(struct bsg_job *bsg_job, scsi_qla_host_t *vha,
                return -ENOMEM;
        }
 
-       memset(ha->optrom_buffer, 0, ha->optrom_region_size);
        return 0;
 }
 
@@ -2314,16 +2313,14 @@ qla2x00_get_priv_stats(struct bsg_job *bsg_job)
        if (!IS_FWI2_CAPABLE(ha))
                return -EPERM;
 
-       stats = dma_alloc_coherent(&ha->pdev->dev,
-               sizeof(*stats), &stats_dma, GFP_KERNEL);
+       stats = dma_zalloc_coherent(&ha->pdev->dev, sizeof(*stats),
+                                   &stats_dma, GFP_KERNEL);
        if (!stats) {
                ql_log(ql_log_warn, vha, 0x70e2,
                    "Failed to allocate memory for stats.\n");
                return -ENOMEM;
        }
 
-       memset(stats, 0, sizeof(*stats));
-
        rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options);
 
        if (rval == QLA_SUCCESS) {
index 3f82ea1b72dc8739283992b4f425d77692b51e7b..aadfeaac389872f1ffabab94bf85d0ec126710fe 100644 (file)
@@ -1635,16 +1635,13 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport)
                return rc;
        }
 
-       lport->lport_loopid_map = vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid) *
-                               65536);
+       lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
        if (!lport->lport_loopid_map) {
                pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n",
                    sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
                btree_destroy32(&lport->lport_fcport_map);
                return -ENOMEM;
        }
-       memset(lport->lport_loopid_map, 0, sizeof(struct tcm_qla2xxx_fc_loopid)
-              * 65536);
        pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n",
               sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
        return 0;