All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: herbert@gondor.apana.org.au
Cc: marex@denx.de, s.trumtrar@pengutronix.de,
	thomas.lendacky@amd.com, linux@arm.linux.org.uk,
	linux-crypto@vger.kernel.org,
	Fabio Estevam <fabio.estevam@nxp.com>
Subject: [PATCH v2 3/3] crypto: mxs-dcp - provide statesize and import/export()
Date: Wed, 13 Jan 2016 15:52:04 -0200	[thread overview]
Message-ID: <1452707524-7695-3-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1452707524-7695-1-git-send-email-festevam@gmail.com>

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

Currently the mxs-dcp driver fails to probe:

mxs-dcp 80028000.dcp: Failed to register sha1 hash!
mxs-dcp: probe of 80028000.dcp failed with error -22

This happens since commit 8996eafdcbad ("crypto: ahash - ensure statesize
is non-zero"), which requires statesize to be filled.

Other than filling statesize, we also need to provide the import/export
functions.

Based on the implementation of the sahara and caam drivers.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
Changes since v2:
- Newly introduced in this series

 drivers/crypto/mxs-dcp.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 59ed54e..1e2017f 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -775,6 +775,24 @@ static void dcp_sha_cra_exit(struct crypto_tfm *tfm)
 {
 }
 
+static int dcp_sha_export(struct ahash_request *req, void *out)
+{
+	struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
+
+	memcpy(out, rctx, sizeof(struct dcp_sha_req_ctx));
+
+	return 0;
+}
+
+static int dcp_sha_import(struct ahash_request *req, const void *in)
+{
+	struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
+
+	memcpy(rctx, in, sizeof(struct dcp_sha_req_ctx));
+
+	return 0;
+}
+
 /* AES 128 ECB and AES 128 CBC */
 static struct crypto_alg dcp_aes_algs[] = {
 	{
@@ -834,8 +852,11 @@ static struct ahash_alg dcp_sha1_alg = {
 	.final	= dcp_sha_final,
 	.finup	= dcp_sha_finup,
 	.digest	= dcp_sha_digest,
+	.import = dcp_sha_import,
+	.export = dcp_sha_export,
 	.halg	= {
 		.digestsize	= SHA1_DIGEST_SIZE,
+		.statesize	= sizeof(struct dcp_sha_req_ctx),
 		.base		= {
 			.cra_name		= "sha1",
 			.cra_driver_name	= "sha1-dcp",
@@ -858,8 +879,11 @@ static struct ahash_alg dcp_sha256_alg = {
 	.final	= dcp_sha_final,
 	.finup	= dcp_sha_finup,
 	.digest	= dcp_sha_digest,
+	.import = dcp_sha_import,
+	.export = dcp_sha_export,
 	.halg	= {
 		.digestsize	= SHA256_DIGEST_SIZE,
+		.statesize	= sizeof(struct dcp_sha_req_ctx),
 		.base		= {
 			.cra_name		= "sha256",
 			.cra_driver_name	= "sha256-dcp",
-- 
1.9.1

  parent reply	other threads:[~2016-01-13 17:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13 17:52 [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Fabio Estevam
2016-01-13 17:52 ` [PATCH v2 2/3] crypto: sahara - fill the statesize field Fabio Estevam
2016-01-13 17:52 ` Fabio Estevam [this message]
2016-01-25 14:10   ` [PATCH v2 3/3] crypto: mxs-dcp - provide statesize and import/export() Herbert Xu
2016-01-25 14:07 ` [PATCH v2 1/3] crypto: sahara - avoid needlessly saving and restoring sahara_ctx Herbert Xu
2016-02-02 13:41   ` Fabio Estevam
2016-02-02 14:43     ` Herbert Xu
2016-02-02 17:18       ` Fabio Estevam
2016-02-03 11:22         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452707524-7695-3-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=fabio.estevam@nxp.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=marex@denx.de \
    --cc=s.trumtrar@pengutronix.de \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.