diff mbox

scsi: qla4xxx: Use dma_pool_zalloc()

Message ID 20180214190020.GA5566@jordon-HP-15-Notebook-PC (mailing list archive)
State Accepted
Headers show

Commit Message

Souptick Joarder Feb. 14, 2018, 7 p.m. UTC
Use dma_pool_zalloc() instead of dma_pool_alloc + memset

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
---
 drivers/scsi/qla4xxx/ql4_mbx.c | 6 ++----
 drivers/scsi/qla4xxx/ql4_os.c  | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)

--
1.9.1

Comments

Rangankar, Manish Feb. 19, 2018, 4:26 a.m. UTC | #1
On 15/02/18 12:30 AM, "Souptick Joarder" <jrdr.linux@gmail.com> wrote:

>Use dma_pool_zalloc() instead of dma_pool_alloc + memset
>
>Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
>---
> drivers/scsi/qla4xxx/ql4_mbx.c | 6 ++----
> drivers/scsi/qla4xxx/ql4_os.c  | 4 +---
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c
>b/drivers/scsi/qla4xxx/ql4_mbx.c
>index bda2e64..5d56904 100644
>--- a/drivers/scsi/qla4xxx/ql4_mbx.c
>+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
>@@ -1584,12 +1584,11 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha,
>char *username, char *password,
> 	struct ql4_chap_table *chap_table;
> 	dma_addr_t chap_dma;
>
>-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
>+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
> 	if (chap_table == NULL)
> 		return -ENOMEM;
>
> 	chap_size = sizeof(struct ql4_chap_table);
>-	memset(chap_table, 0, chap_size);
>
> 	if (is_qla40XX(ha))
> 		offset = FLASH_CHAP_OFFSET | (idx * chap_size);
>@@ -1648,13 +1647,12 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha,
>char *username, char *password,
> 	uint32_t chap_size = 0;
> 	dma_addr_t chap_dma;
>
>-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
>+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
> 	if (chap_table == NULL) {
> 		ret =  -ENOMEM;
> 		goto exit_set_chap;
> 	}
>
>-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
> 	if (bidi)
> 		chap_table->flags |= BIT_6; /* peer */
> 	else
>diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
>index 82e889b..5896343 100644
>--- a/drivers/scsi/qla4xxx/ql4_os.c
>+++ b/drivers/scsi/qla4xxx/ql4_os.c
>@@ -825,12 +825,10 @@ static int qla4xxx_delete_chap(struct Scsi_Host
>*shost, uint16_t chap_tbl_idx)
> 	uint32_t chap_size;
> 	int ret = 0;
>
>-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
>+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
> 	if (chap_table == NULL)
> 		return -ENOMEM;
>
>-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
>-
> 	if (is_qla80XX(ha))
> 		max_chap_entries = (ha->hw.flt_chap_size / 2) /
> 				   sizeof(struct ql4_chap_table);
>--
>1.9.1

Thanks,

Acked-by: Manish Rangankar <Manish.Rangankar@cavium.com>
Martin K. Petersen Feb. 22, 2018, 3:35 a.m. UTC | #2
Souptick,

> Use dma_pool_zalloc() instead of dma_pool_alloc + memset

Applied to 4.17/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index bda2e64..5d56904 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1584,12 +1584,11 @@  int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
 	struct ql4_chap_table *chap_table;
 	dma_addr_t chap_dma;

-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
 	if (chap_table == NULL)
 		return -ENOMEM;

 	chap_size = sizeof(struct ql4_chap_table);
-	memset(chap_table, 0, chap_size);

 	if (is_qla40XX(ha))
 		offset = FLASH_CHAP_OFFSET | (idx * chap_size);
@@ -1648,13 +1647,12 @@  int qla4xxx_set_chap(struct scsi_qla_host *ha, char *username, char *password,
 	uint32_t chap_size = 0;
 	dma_addr_t chap_dma;

-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
 	if (chap_table == NULL) {
 		ret =  -ENOMEM;
 		goto exit_set_chap;
 	}

-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
 	if (bidi)
 		chap_table->flags |= BIT_6; /* peer */
 	else
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 82e889b..5896343 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -825,12 +825,10 @@  static int qla4xxx_delete_chap(struct Scsi_Host *shost, uint16_t chap_tbl_idx)
 	uint32_t chap_size;
 	int ret = 0;

-	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+	chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
 	if (chap_table == NULL)
 		return -ENOMEM;

-	memset(chap_table, 0, sizeof(struct ql4_chap_table));
-
 	if (is_qla80XX(ha))
 		max_chap_entries = (ha->hw.flt_chap_size / 2) /
 				   sizeof(struct ql4_chap_table);