All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc()
@ 2014-01-29  0:36 Fabio Estevam
  2014-01-29  0:36 ` [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block() Fabio Estevam
  2014-01-29  0:58 ` [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Marek Vasut
  0 siblings, 2 replies; 5+ messages in thread
From: Fabio Estevam @ 2014-01-29  0:36 UTC (permalink / raw)
  To: herbert; +Cc: marex, linux-crypto, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

Using devm_kzalloc() can make the code cleaner.

While at it, remove the devm_kzalloc error message as there is standard OOM
message done by the core.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/crypto/mxs-dcp.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index a6db7fa..2d7d497 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -935,9 +935,8 @@ static int mxs_dcp_probe(struct platform_device *pdev)
 	}
 
 	/* Allocate coherent helper block. */
-	sdcp->coh = kzalloc(sizeof(struct dcp_coherent_block), GFP_KERNEL);
+	sdcp->coh = devm_kzalloc(dev, sizeof(*sdcp->coh), GFP_KERNEL);
 	if (!sdcp->coh) {
-		dev_err(dev, "Error allocating coherent block\n");
 		ret = -ENOMEM;
 		goto err_mutex;
 	}
@@ -982,7 +981,7 @@ static int mxs_dcp_probe(struct platform_device *pdev)
 	if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) {
 		dev_err(dev, "Error starting SHA thread!\n");
 		ret = PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]);
-		goto err_free_coherent;
+		goto err_mutex;
 	}
 
 	sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes,
@@ -1040,8 +1039,6 @@ err_destroy_aes_thread:
 err_destroy_sha_thread:
 	kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]);
 
-err_free_coherent:
-	kfree(sdcp->coh);
 err_mutex:
 	mutex_unlock(&global_mutex);
 	return ret;
@@ -1051,8 +1048,6 @@ static int mxs_dcp_remove(struct platform_device *pdev)
 {
 	struct dcp *sdcp = platform_get_drvdata(pdev);
 
-	kfree(sdcp->coh);
-
 	if (sdcp->caps & MXS_DCP_CAPABILITY1_SHA256)
 		crypto_unregister_ahash(&dcp_sha256_alg);
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block()
  2014-01-29  0:36 [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Fabio Estevam
@ 2014-01-29  0:36 ` Fabio Estevam
  2014-01-29  0:58   ` Marek Vasut
  2014-01-29  0:58 ` [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Marek Vasut
  1 sibling, 1 reply; 5+ messages in thread
From: Fabio Estevam @ 2014-01-29  0:36 UTC (permalink / raw)
  To: herbert; +Cc: marex, linux-crypto, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

stmp_reset_block() may fail, so check its return value and propagate it in the
case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/crypto/mxs-dcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 2d7d497..4d18c40 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -942,7 +942,9 @@ static int mxs_dcp_probe(struct platform_device *pdev)
 	}
 
 	/* Restart the DCP block. */
-	stmp_reset_block(sdcp->base);
+	ret = stmp_reset_block(sdcp->base);
+	if (ret)
+		goto err_mutex;
 
 	/* Initialize control register. */
 	writel(MXS_DCP_CTRL_GATHER_RESIDUAL_WRITES |
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc()
  2014-01-29  0:36 [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Fabio Estevam
  2014-01-29  0:36 ` [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block() Fabio Estevam
@ 2014-01-29  0:58 ` Marek Vasut
  2014-02-09  9:22   ` Herbert Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Marek Vasut @ 2014-01-29  0:58 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: herbert, linux-crypto, Fabio Estevam

On Wednesday, January 29, 2014 at 01:36:11 AM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Using devm_kzalloc() can make the code cleaner.
> 
> While at it, remove the devm_kzalloc error message as there is standard OOM
> message done by the core.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block()
  2014-01-29  0:36 ` [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block() Fabio Estevam
@ 2014-01-29  0:58   ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2014-01-29  0:58 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: herbert, linux-crypto, Fabio Estevam

On Wednesday, January 29, 2014 at 01:36:12 AM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> stmp_reset_block() may fail, so check its return value and propagate it in
> the case of error.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc()
  2014-01-29  0:58 ` [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Marek Vasut
@ 2014-02-09  9:22   ` Herbert Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2014-02-09  9:22 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Fabio Estevam, linux-crypto, Fabio Estevam

On Wed, Jan 29, 2014 at 01:58:15AM +0100, Marek Vasut wrote:
> On Wednesday, January 29, 2014 at 01:36:11 AM, Fabio Estevam wrote:
> > From: Fabio Estevam <fabio.estevam@freescale.com>
> > 
> > Using devm_kzalloc() can make the code cleaner.
> > 
> > While at it, remove the devm_kzalloc error message as there is standard OOM
> > message done by the core.
> > 
> > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Acked-by: Marek Vasut <marex@denx.de>

Both patches applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-09  9:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-29  0:36 [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Fabio Estevam
2014-01-29  0:36 ` [PATCH 2/2] crypto: mxs-dcp: Check the return value of stmp_reset_block() Fabio Estevam
2014-01-29  0:58   ` Marek Vasut
2014-01-29  0:58 ` [PATCH 1/2] crypto: mxs-dcp: Use devm_kzalloc() Marek Vasut
2014-02-09  9:22   ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.