Commit 9c4f9733 authored by Fabio Estevam's avatar Fabio Estevam Committed by Herbert Xu

crypto: caam - Use the preferred style for memory allocations

"The preferred form for passing a size of a struct is the following:

        p = kmalloc(sizeof(*p), ...);
....

The preferred form for allocating a zeroed array is the following:

        p = kcalloc(n, sizeof(...), ...); "

,so do as suggested.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: default avatarHoria Geant? <horia.geanta@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a3c09550
...@@ -4314,7 +4314,7 @@ static struct caam_crypto_alg *caam_alg_alloc(struct caam_alg_template ...@@ -4314,7 +4314,7 @@ static struct caam_crypto_alg *caam_alg_alloc(struct caam_alg_template
struct caam_crypto_alg *t_alg; struct caam_crypto_alg *t_alg;
struct crypto_alg *alg; struct crypto_alg *alg;
t_alg = kzalloc(sizeof(struct caam_crypto_alg), GFP_KERNEL); t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
if (!t_alg) { if (!t_alg) {
pr_err("failed to allocate t_alg\n"); pr_err("failed to allocate t_alg\n");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -1841,7 +1841,7 @@ caam_hash_alloc(struct caam_hash_template *template, ...@@ -1841,7 +1841,7 @@ caam_hash_alloc(struct caam_hash_template *template,
struct ahash_alg *halg; struct ahash_alg *halg;
struct crypto_alg *alg; struct crypto_alg *alg;
t_alg = kzalloc(sizeof(struct caam_hash_alg), GFP_KERNEL); t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
if (!t_alg) { if (!t_alg) {
pr_err("failed to allocate t_alg\n"); pr_err("failed to allocate t_alg\n");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -351,7 +351,7 @@ static int __init caam_rng_init(void) ...@@ -351,7 +351,7 @@ static int __init caam_rng_init(void)
pr_err("Job Ring Device allocation for transform failed\n"); pr_err("Job Ring Device allocation for transform failed\n");
return PTR_ERR(dev); return PTR_ERR(dev);
} }
rng_ctx = kmalloc(sizeof(struct caam_rng_ctx), GFP_DMA); rng_ctx = kmalloc(sizeof(*rng_ctx), GFP_DMA);
if (!rng_ctx) { if (!rng_ctx) {
err = -ENOMEM; err = -ENOMEM;
goto free_caam_alloc; goto free_caam_alloc;
......
...@@ -424,8 +424,7 @@ static int caam_probe(struct platform_device *pdev) ...@@ -424,8 +424,7 @@ static int caam_probe(struct platform_device *pdev)
int pg_size; int pg_size;
int BLOCK_OFFSET = 0; int BLOCK_OFFSET = 0;
ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(struct caam_drv_private), ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL);
GFP_KERNEL);
if (!ctrlpriv) if (!ctrlpriv)
return -ENOMEM; return -ENOMEM;
...@@ -583,9 +582,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -583,9 +582,8 @@ static int caam_probe(struct platform_device *pdev)
of_device_is_compatible(np, "fsl,sec4.0-job-ring")) of_device_is_compatible(np, "fsl,sec4.0-job-ring"))
rspec++; rspec++;
ctrlpriv->jrpdev = devm_kzalloc(&pdev->dev, ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec,
sizeof(struct platform_device *) * rspec, sizeof(*ctrlpriv->jrpdev), GFP_KERNEL);
GFP_KERNEL);
if (ctrlpriv->jrpdev == NULL) { if (ctrlpriv->jrpdev == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto iounmap_ctrl; goto iounmap_ctrl;
......
...@@ -410,18 +410,17 @@ static int caam_jr_init(struct device *dev) ...@@ -410,18 +410,17 @@ static int caam_jr_init(struct device *dev)
goto out_free_irq; goto out_free_irq;
error = -ENOMEM; error = -ENOMEM;
jrp->inpring = dma_alloc_coherent(dev, sizeof(dma_addr_t) * JOBR_DEPTH, jrp->inpring = dma_alloc_coherent(dev, sizeof(*jrp->inpring) *
&inpbusaddr, GFP_KERNEL); JOBR_DEPTH, &inpbusaddr, GFP_KERNEL);
if (!jrp->inpring) if (!jrp->inpring)
goto out_free_irq; goto out_free_irq;
jrp->outring = dma_alloc_coherent(dev, sizeof(struct jr_outentry) * jrp->outring = dma_alloc_coherent(dev, sizeof(*jrp->outring) *
JOBR_DEPTH, &outbusaddr, GFP_KERNEL); JOBR_DEPTH, &outbusaddr, GFP_KERNEL);
if (!jrp->outring) if (!jrp->outring)
goto out_free_inpring; goto out_free_inpring;
jrp->entinfo = kzalloc(sizeof(struct caam_jrentry_info) * JOBR_DEPTH, jrp->entinfo = kcalloc(JOBR_DEPTH, sizeof(*jrp->entinfo), GFP_KERNEL);
GFP_KERNEL);
if (!jrp->entinfo) if (!jrp->entinfo)
goto out_free_outring; goto out_free_outring;
...@@ -479,8 +478,7 @@ static int caam_jr_probe(struct platform_device *pdev) ...@@ -479,8 +478,7 @@ static int caam_jr_probe(struct platform_device *pdev)
int error; int error;
jrdev = &pdev->dev; jrdev = &pdev->dev;
jrpriv = devm_kmalloc(jrdev, sizeof(struct caam_drv_private_jr), jrpriv = devm_kmalloc(jrdev, sizeof(*jrpriv), GFP_KERNEL);
GFP_KERNEL);
if (!jrpriv) if (!jrpriv)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment