crypto: Use zeroing memory allocator instead of allocator/memset
authorHimanshu Jha <himanshujha199640@gmail.com>
Sun, 31 Dec 2017 12:24:23 +0000 (17:54 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 12 Jan 2018 12:02:56 +0000 (23:02 +1100)
Use dma_zalloc_coherent 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.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/ixp4xx_crypto.c

index ad19aa8069317d769f012ebf53cd98b8a5bfa185..76f459ad28214c15842192938c1c50ac72db9368 100644 (file)
@@ -282,14 +282,12 @@ static u32 crypto4xx_put_pd_to_pdr(struct crypto4xx_device *dev, u32 idx)
  */
 static u32 crypto4xx_build_gdr(struct crypto4xx_device *dev)
 {
-       dev->gdr = dma_alloc_coherent(dev->core_dev->device,
-                                     sizeof(struct ce_gd) * PPC4XX_NUM_GD,
-                                     &dev->gdr_pa, GFP_ATOMIC);
+       dev->gdr = dma_zalloc_coherent(dev->core_dev->device,
+                                      sizeof(struct ce_gd) * PPC4XX_NUM_GD,
+                                      &dev->gdr_pa, GFP_ATOMIC);
        if (!dev->gdr)
                return -ENOMEM;
 
-       memset(dev->gdr, 0, sizeof(struct ce_gd) * PPC4XX_NUM_GD);
-
        return 0;
 }
 
index 8705b28eb02c6375981687b1ee105e384e166c5a..717a26607bdbbaf0143c969805f82bdb8bb8ffa8 100644 (file)
@@ -260,12 +260,11 @@ static int setup_crypt_desc(void)
 {
        struct device *dev = &pdev->dev;
        BUILD_BUG_ON(sizeof(struct crypt_ctl) != 64);
-       crypt_virt = dma_alloc_coherent(dev,
-                       NPE_QLEN * sizeof(struct crypt_ctl),
-                       &crypt_phys, GFP_ATOMIC);
+       crypt_virt = dma_zalloc_coherent(dev,
+                                        NPE_QLEN * sizeof(struct crypt_ctl),
+                                        &crypt_phys, GFP_ATOMIC);
        if (!crypt_virt)
                return -ENOMEM;
-       memset(crypt_virt, 0, NPE_QLEN * sizeof(struct crypt_ctl));
        return 0;
 }