linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: clabbe.montjoie@gmail.com (Corentin Labbe)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/6] crypto: stm32-hash: convert to the new crypto engine API
Date: Wed,  3 Jan 2018 21:11:08 +0100	[thread overview]
Message-ID: <20180103201109.16077-6-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <20180103201109.16077-1-clabbe.montjoie@gmail.com>

This patch convert the stm32-hash driver to the new crypto engine API.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/stm32/stm32-hash.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
index 4ca4a264a833..9790c2c936c7 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -122,6 +122,7 @@ enum stm32_hash_data_format {
 #define HASH_DMA_THRESHOLD		50
 
 struct stm32_hash_ctx {
+	struct crypto_engine_reqctx enginectx;
 	struct stm32_hash_dev	*hdev;
 	unsigned long		flags;
 
@@ -828,6 +829,11 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev,
 	return 0;
 }
 
+static int stm32_hash_one_request(struct crypto_engine *engine,
+				  void *areq);
+static int stm32_hash_prepare_req(struct crypto_engine *engine,
+				  void *areq);
+
 static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev,
 				   struct ahash_request *req)
 {
@@ -835,8 +841,9 @@ static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev,
 }
 
 static int stm32_hash_prepare_req(struct crypto_engine *engine,
-				  struct ahash_request *req)
+				  void *areq)
 {
+	struct ahash_request *req = container_of(areq, struct ahash_request, base);
 	struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
 	struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx);
 	struct stm32_hash_request_ctx *rctx;
@@ -855,8 +862,9 @@ static int stm32_hash_prepare_req(struct crypto_engine *engine,
 }
 
 static int stm32_hash_one_request(struct crypto_engine *engine,
-				  struct ahash_request *req)
+				  void *areq)
 {
+	struct ahash_request *req = container_of(areq, struct ahash_request, base);
 	struct stm32_hash_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
 	struct stm32_hash_dev *hdev = stm32_hash_find_dev(ctx);
 	struct stm32_hash_request_ctx *rctx;
@@ -1033,6 +1041,9 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm,
 	if (algs_hmac_name)
 		ctx->flags |= HASH_FLAGS_HMAC;
 
+	ctx->enginectx.op.do_one_request = stm32_hash_one_request;
+	ctx->enginectx.op.prepare_request = stm32_hash_prepare_req;
+	ctx->enginectx.op.unprepare_request = NULL;
 	return 0;
 }
 
@@ -1493,9 +1504,6 @@ static int stm32_hash_probe(struct platform_device *pdev)
 		goto err_engine;
 	}
 
-	hdev->engine->prepare_hash_request = stm32_hash_prepare_req;
-	hdev->engine->hash_one_request = stm32_hash_one_request;
-
 	ret = crypto_engine_start(hdev->engine);
 	if (ret)
 		goto err_engine_start;
-- 
2.13.6

  parent reply	other threads:[~2018-01-03 20:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03 20:11 [PATCH 0/6] crypto: engine - Permit to enqueue all async requests Corentin Labbe
2018-01-03 20:11 ` [PATCH 1/6] Documentation: crypto: document crypto engine API Corentin Labbe
2018-01-10 14:13   ` Fabien DESSENNE
2018-01-10 19:14     ` Corentin Labbe
2018-01-03 20:11 ` [PATCH 2/6] crypto: engine - Permit to enqueue all async requests Corentin Labbe
2018-01-10 14:19   ` Fabien DESSENNE
2018-01-11  7:44     ` Fabien DESSENNE
2018-01-12  7:14   ` Herbert Xu
2018-01-03 20:11 ` [PATCH 3/6] crypto: omap: convert to new crypto engine API Corentin Labbe
2018-01-03 20:11 ` [PATCH 4/6] crypto: virtio: " Corentin Labbe
2018-01-03 20:11 ` Corentin Labbe [this message]
2018-01-10 14:24   ` [PATCH 5/6] crypto: stm32-hash: convert to the " Fabien DESSENNE
2018-01-11  7:44     ` Fabien DESSENNE
2018-01-03 20:11 ` [PATCH 6/6] crypto: stm32-cryp: " Corentin Labbe
2018-01-10 14:25   ` Fabien DESSENNE
2018-01-11  7:45     ` Fabien DESSENNE

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=20180103201109.16077-6-clabbe.montjoie@gmail.com \
    --to=clabbe.montjoie@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).