[1/3] scsi: qla2xxx: Replace vmalloc + memset with vzalloc
diff mbox series

Message ID 20190718074518.16273-1-hslester96@gmail.com
State Accepted
Headers show
Series
  • [1/3] scsi: qla2xxx: Replace vmalloc + memset with vzalloc
Related show

Commit Message

Chuhong Yuan July 18, 2019, 7:45 a.m. UTC
Use vzalloc instead of using vmalloc to allocate memory
and then zeroing it with memset.
This simplifies the code.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---

 drivers/scsi/qla2xxx/qla_attr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Martin K. Petersen July 30, 2019, 4:21 p.m. UTC | #1
Chuhong,

> Use vzalloc instead of using vmalloc to allocate memory and then
> zeroing it with memset.  This simplifies the code.

Applied to 5.4/scsi-queue. Thanks!

Patch
diff mbox series

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 8d560c562e9c..2b92d4659934 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -382,7 +382,7 @@  qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		ha->optrom_region_size = size;
 
 		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 == NULL) {
 			ql_log(ql_log_warn, vha, 0x7062,
 			    "Unable to allocate memory for optrom retrieval "
@@ -404,7 +404,6 @@  qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		    "Reading flash region -- 0x%x/0x%x.\n",
 		    ha->optrom_region_start, ha->optrom_region_size);
 
-		memset(ha->optrom_buffer, 0, ha->optrom_region_size);
 		ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
 		    ha->optrom_region_start, ha->optrom_region_size);
 		break;
@@ -457,7 +456,7 @@  qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		ha->optrom_region_size = size;
 
 		ha->optrom_state = QLA_SWRITING;
-		ha->optrom_buffer = vmalloc(ha->optrom_region_size);
+		ha->optrom_buffer = vzalloc(ha->optrom_region_size);
 		if (ha->optrom_buffer == NULL) {
 			ql_log(ql_log_warn, vha, 0x7066,
 			    "Unable to allocate memory for optrom update "
@@ -472,7 +471,6 @@  qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		    "Staging flash region write -- 0x%x/0x%x.\n",
 		    ha->optrom_region_start, ha->optrom_region_size);
 
-		memset(ha->optrom_buffer, 0, ha->optrom_region_size);
 		break;
 	case 3:
 		if (ha->optrom_state != QLA_SWRITING) {