2019-05-29 20:23:04

by Thomas Meyer

[permalink] [raw]
Subject: Cocci spatch "pool_zalloc-simple" - v5.2-rc1

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.

Found by coccinelle spatch "api/alloc/pool_zalloc-simple.cocci"

Run against version v5.2-rc1

P.S. If you find this email unwanted, set up a procmail rule junking on
the header:

X-Patch: Cocci


2019-05-29 20:23:04

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH] scsi: lpfc: Use *_pool_zalloc rather than *_pool_alloc

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4114,14 +4114,13 @@ lpfc_new_io_buf(struct lpfc_hba *phba, i
* pci bus space for an I/O. The DMA buffer includes the
* number of SGE's necessary to support the sg_tablesize.
*/
- lpfc_ncmd->data = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool,
- GFP_KERNEL,
- &lpfc_ncmd->dma_handle);
+ lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool,
+ GFP_KERNEL,
+ &lpfc_ncmd->dma_handle);
if (!lpfc_ncmd->data) {
kfree(lpfc_ncmd);
break;
}
- memset(lpfc_ncmd->data, 0, phba->cfg_sg_dma_buf_size);

/*
* 4K Page alignment is CRITICAL to BlockGuard, double check

2019-05-29 20:23:21

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH] scsi: pmcraid: Use *_pool_zalloc rather than *_pool_alloc

Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.

Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4668,18 +4668,14 @@ static int pmcraid_allocate_control_bloc
return -ENOMEM;

for (i = 0; i < PMCRAID_MAX_CMD; i++) {
- pinstance->cmd_list[i]->ioa_cb =
- dma_pool_alloc(
- pinstance->control_pool,
- GFP_KERNEL,
- &(pinstance->cmd_list[i]->ioa_cb_bus_addr));
+ pinstance->cmd_list[i]->ioa_cb = dma_pool_zalloc(pinstance->control_pool,
+ GFP_KERNEL,
+ &(pinstance->cmd_list[i]->ioa_cb_bus_addr));

if (!pinstance->cmd_list[i]->ioa_cb) {
pmcraid_release_control_blocks(pinstance, i);
return -ENOMEM;
}
- memset(pinstance->cmd_list[i]->ioa_cb, 0,
- sizeof(struct pmcraid_control_block));
}
return 0;
}

2019-05-30 00:34:01

by James Smart

[permalink] [raw]
Subject: Re: [PATCH] scsi: lpfc: Use *_pool_zalloc rather than *_pool_alloc



On 5/29/2019 1:21 PM, Thomas Meyer wrote:
> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
>
> Signed-off-by: Thomas Meyer <[email protected]>
> ---
>
>

looks good

Reviewed-by: James Smart <[email protected]>

-- james

2019-05-30 02:08:31

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH] scsi: lpfc: Use *_pool_zalloc rather than *_pool_alloc


Thomas,

> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.

Applied to 5.3/scsi-queue. Thanks!

--
Martin K. Petersen Oracle Linux Engineering

2019-11-03 16:07:15

by Markus Elfring

[permalink] [raw]
Subject: Re: scsi: pmcraid: Use *_pool_zalloc rather than *_pool_alloc

> Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.

Do you find a commit message nicer from a similar change suggestion?
scsi: pmcraid: Use dma_pool_zalloc rather than dma_pool_alloc
https://lore.kernel.org/linux-scsi/[email protected]/
https://lore.kernel.org/patchwork/patch/1102040/

Regards,
Markus

2019-11-14 09:00:49

by Vasyl Gomonovych

[permalink] [raw]
Subject: Re: scsi: pmcraid: Use *_pool_zalloc rather than *_pool_alloc

Hi,

Yes, maybe you are right better to use the full name, sorry.

Regards Vasyl

On Sun, Nov 3, 2019 at 5:05 PM Markus Elfring <[email protected]> wrote:
>
> > Use *_pool_zalloc rather than *_pool_alloc followed by memset with 0.
>
> Do you find a commit message nicer from a similar change suggestion?
> scsi: pmcraid: Use dma_pool_zalloc rather than dma_pool_alloc
> https://lore.kernel.org/linux-scsi/[email protected]/
> https://lore.kernel.org/patchwork/patch/1102040/
>
> Regards,
> Markus



--
Доброї вам пори дня.