From: Himanshu Jha <himanshujha199640@gmail.com>
To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, aacraid@adaptec.com
Cc: anil.gurumurthy@qlogic.com, sudarsana.kalluru@qlogic.com,
QLogic-Storage-Upstream@qlogic.com, satishkh@cisco.com,
sebaddel@cisco.com, kartilak@cisco.com,
QLogic-Storage-Upstream@cavium.com, qla2xxx-upstream@qlogic.com,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Himanshu Jha <himanshujha199640@gmail.com>
Subject: [PATCH 2/9] scsi: qla2xxx: Use zeroing allocator rather than allocator/memset
Date: Sat, 30 Dec 2017 20:58:25 +0530 [thread overview]
Message-ID: <1514647712-6332-3-git-send-email-himanshujha199640@gmail.com> (raw)
In-Reply-To: <1514647712-6332-1-git-send-email-himanshujha199640@gmail.com>
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>
---
drivers/scsi/qla2xxx/qla_attr.c | 5 ++---
drivers/scsi/qla2xxx/qla_bsg.c | 9 +++------
drivers/scsi/qla2xxx/tcm_qla2xxx.c | 5 +----
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 9ce28c4..f46b015 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -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)) {
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index e3ac707..e2d5d3c 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -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) {
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 3f82ea1..aadfeaa 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -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;
--
2.7.4
next prev parent reply other threads:[~2017-12-30 15:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-30 15:28 [PATCH 0/9] scsi: Use zeroing allocators than allocator/memset Himanshu Jha
2017-12-30 15:28 ` [PATCH 1/9] scsi: qla4xxx: Use zeroing allocator rather " Himanshu Jha
2018-01-02 4:39 ` Rangankar, Manish
2018-01-04 6:08 ` Martin K. Petersen
2017-12-30 15:28 ` Himanshu Jha [this message]
2018-01-02 17:01 ` [PATCH 2/9] scsi: qla2xxx: " Madhani, Himanshu
2018-01-04 6:09 ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 3/9] scsi: qedi: Use zeroing allocator instead of allocator/memset Himanshu Jha
2018-01-02 4:40 ` Rangankar, Manish
2018-01-04 6:17 ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 4/9] scsi: mvsas: Use zeroing allocator rather than allocator/memset Himanshu Jha
2017-12-30 15:28 ` [PATCH 5/9] scsi: fnic: " Himanshu Jha
2017-12-30 15:28 ` [PATCH 6/9] scsi: dpt_i2o: " Himanshu Jha
2017-12-30 15:28 ` [PATCH 7/9] scsi: bnx2fc: " Himanshu Jha
2018-01-02 21:14 ` Chad Dupuis
2018-01-04 6:17 ` Martin K. Petersen
2018-01-04 7:38 ` Himanshu Jha
2018-01-09 3:35 ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 8/9] scsi: bfa: " Himanshu Jha
2018-01-02 5:40 ` Gurumurthy, Anil
2018-01-04 6:13 ` Martin K. Petersen
2017-12-30 15:28 ` [PATCH 9/9] scsi: bnx2i: " Himanshu Jha
2018-01-02 4:42 ` Rangankar, Manish
2018-01-04 6:13 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1514647712-6332-3-git-send-email-himanshujha199640@gmail.com \
--to=himanshujha199640@gmail.com \
--cc=QLogic-Storage-Upstream@cavium.com \
--cc=QLogic-Storage-Upstream@qlogic.com \
--cc=aacraid@adaptec.com \
--cc=anil.gurumurthy@qlogic.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=kartilak@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=qla2xxx-upstream@qlogic.com \
--cc=satishkh@cisco.com \
--cc=sebaddel@cisco.com \
--cc=sudarsana.kalluru@qlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).