Skip to content

Commit 5f58dff

Browse files
himanshujha199640davem330
authored andcommitted
qed: Use zeroing memory allocator than allocator/memset
Use dma_zalloc_coherent and vzalloc for allocating zeroed memory and remove unnecessary memset function. Done using Coccinelle. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci 0-day tested with no failures. Suggested-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Acked-by: Tomer Tayar <Tomer.Tayar@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3288ed6 commit 5f58dff

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

drivers/net/ethernet/qlogic/qed/qed_cxt.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,10 @@ static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
10551055
u32 size;
10561056

10571057
size = min_t(u32, sz_left, p_blk->real_size_in_page);
1058-
p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
1059-
size, &p_phys, GFP_KERNEL);
1058+
p_virt = dma_zalloc_coherent(&p_hwfn->cdev->pdev->dev, size,
1059+
&p_phys, GFP_KERNEL);
10601060
if (!p_virt)
10611061
return -ENOMEM;
1062-
memset(p_virt, 0, size);
10631062

10641063
ilt_shadow[line].p_phys = p_phys;
10651064
ilt_shadow[line].p_virt = p_virt;
@@ -2308,14 +2307,13 @@ qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
23082307
goto out0;
23092308
}
23102309

2311-
p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
2312-
p_blk->real_size_in_page,
2313-
&p_phys, GFP_KERNEL);
2310+
p_virt = dma_zalloc_coherent(&p_hwfn->cdev->pdev->dev,
2311+
p_blk->real_size_in_page, &p_phys,
2312+
GFP_KERNEL);
23142313
if (!p_virt) {
23152314
rc = -ENOMEM;
23162315
goto out1;
23172316
}
2318-
memset(p_virt, 0, p_blk->real_size_in_page);
23192317

23202318
/* configuration of refTagMask to 0xF is required for RoCE DIF MR only,
23212319
* to compensate for a HW bug, but it is configured even if DIF is not

drivers/net/ethernet/qlogic/qed/qed_l2.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ _qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
223223
struct qed_queue_cid *p_cid;
224224
int rc;
225225

226-
p_cid = vmalloc(sizeof(*p_cid));
226+
p_cid = vzalloc(sizeof(*p_cid));
227227
if (!p_cid)
228228
return NULL;
229-
memset(p_cid, 0, sizeof(*p_cid));
230229

231230
p_cid->opaque_fid = opaque_fid;
232231
p_cid->cid = cid;

0 commit comments

Comments
 (0)