qed: Use zeroing memory allocator than allocator/memset
authorHimanshu Jha <himanshujha199640@gmail.com>
Sat, 30 Dec 2017 15:37:04 +0000 (21:07 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Jan 2018 02:55:43 +0000 (21:55 -0500)
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>
drivers/net/ethernet/qlogic/qed/qed_cxt.c
drivers/net/ethernet/qlogic/qed/qed_l2.c

index ad4a3fdd4cb4010f140848eed3c3bd5e2d906e06..6f546e869d8d69fd17c7eaeeec579d1134d3364d 100644 (file)
@@ -1055,11 +1055,10 @@ static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
                u32 size;
 
                size = min_t(u32, sz_left, p_blk->real_size_in_page);
-               p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
-                                           size, &p_phys, GFP_KERNEL);
+               p_virt = dma_zalloc_coherent(&p_hwfn->cdev->pdev->dev, size,
+                                            &p_phys, GFP_KERNEL);
                if (!p_virt)
                        return -ENOMEM;
-               memset(p_virt, 0, size);
 
                ilt_shadow[line].p_phys = p_phys;
                ilt_shadow[line].p_virt = p_virt;
@@ -2308,14 +2307,13 @@ qed_cxt_dynamic_ilt_alloc(struct qed_hwfn *p_hwfn,
                goto out0;
        }
 
-       p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
-                                   p_blk->real_size_in_page,
-                                   &p_phys, GFP_KERNEL);
+       p_virt = dma_zalloc_coherent(&p_hwfn->cdev->pdev->dev,
+                                    p_blk->real_size_in_page, &p_phys,
+                                    GFP_KERNEL);
        if (!p_virt) {
                rc = -ENOMEM;
                goto out1;
        }
-       memset(p_virt, 0, p_blk->real_size_in_page);
 
        /* configuration of refTagMask to 0xF is required for RoCE DIF MR only,
         * to compensate for a HW bug, but it is configured even if DIF is not
index 59ecc1e87fafff84657f8e570af20da6f60d73ab..893ef08a4b394ba5e482e4edb0b6b3235f48608d 100644 (file)
@@ -223,10 +223,9 @@ _qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
        struct qed_queue_cid *p_cid;
        int rc;
 
-       p_cid = vmalloc(sizeof(*p_cid));
+       p_cid = vzalloc(sizeof(*p_cid));
        if (!p_cid)
                return NULL;
-       memset(p_cid, 0, sizeof(*p_cid));
 
        p_cid->opaque_fid = opaque_fid;
        p_cid->cid = cid;