prepare/unprepare functions should be able to know which slot in a batch
should be used for preparing a request.

Signed-off-by: Corentin Labbe <clabbe.montj...@gmail.com>
---
 crypto/crypto_engine.c                              | 4 ++--
 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 6 ++----
 drivers/crypto/omap-aes-gcm.c                       | 2 +-
 drivers/crypto/omap-aes.c                           | 4 ++--
 drivers/crypto/omap-des.c                           | 4 ++--
 drivers/crypto/stm32/stm32-cryp.c                   | 8 ++++----
 drivers/crypto/stm32/stm32-hash.c                   | 4 ++--
 include/crypto/engine.h                             | 4 ++--
 8 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c
index 591dea5ddeec..e23a398ba330 100644
--- a/crypto/crypto_engine.c
+++ b/crypto/crypto_engine.c
@@ -40,7 +40,7 @@ static void crypto_finalize_request(struct crypto_engine 
*engine,
                        enginectx = 
crypto_tfm_ctx(engine->cur_reqs[i].req->tfm);
                        if (engine->cur_reqs[i].prepared &&
                            enginectx->op.unprepare_request) {
-                               ret = enginectx->op.unprepare_request(engine, 
engine->cur_reqs[i].req);
+                               ret = enginectx->op.unprepare_request(engine, 
engine->cur_reqs[i].req, i);
                                if (ret)
                                        dev_err(engine->dev, "failed to 
unprepare request\n");
                        }
@@ -143,7 +143,7 @@ static void crypto_pump_requests(struct crypto_engine 
*engine,
        enginectx = crypto_tfm_ctx(async_req->tfm);
 
        if (enginectx->op.prepare_request) {
-               ret = enginectx->op.prepare_request(engine, async_req);
+               ret = enginectx->op.prepare_request(engine, async_req, 
engine->ct);
                if (ret) {
                        dev_err(engine->dev, "failed to prepare request: %d\n",
                                ret);
diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c 
b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
index d56c992fbf93..41d18c18d1d1 100644
--- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
+++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
@@ -78,7 +78,7 @@ static int sun8i_ce_cipher_fallback(struct skcipher_request 
*areq)
        return err;
 }
 
-static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void 
*async_req)
+static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void 
*async_req, int slot)
 {
        struct skcipher_request *areq = container_of(async_req, struct 
skcipher_request, base);
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
@@ -96,7 +96,6 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine 
*engine, void *async_req
        int flow, i;
        int nr_sgs = 0;
        int nr_sgd = 0;
-       int slot = 0;
        int err = 0;
 
        if (slot < 0 || slot >= MAXTASK)
@@ -296,7 +295,7 @@ int sun8i_ce_cipher_run(struct crypto_engine *engine, void 
*areq)
        return 0;
 }
 
-static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void 
*async_req)
+static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void 
*async_req, int slot)
 {
        struct skcipher_request *areq = container_of(async_req, struct 
skcipher_request, base);
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
@@ -308,7 +307,6 @@ static int sun8i_ce_cipher_unprepare(struct crypto_engine 
*engine, void *async_r
        unsigned int ivsize, offset;
        int nr_sgs = rctx->nr_sgs;
        int nr_sgd = rctx->nr_sgd;
-       int slot = 0;
        int flow;
 
        flow = rctx->flow;
diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c
index 32dc00dc570b..0fea3dd40378 100644
--- a/drivers/crypto/omap-aes-gcm.c
+++ b/drivers/crypto/omap-aes-gcm.c
@@ -213,7 +213,7 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev 
*dd,
        return 0;
 }
 
-static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq)
+static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq, 
int slot)
 {
        struct aead_request *req = container_of(areq, struct aead_request,
                                                base);
diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index 824ddf2a66ff..4d9caa7ce8da 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -427,7 +427,7 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd,
 }
 
 static int omap_aes_prepare_req(struct crypto_engine *engine,
-                               void *areq)
+                               void *areq, int slot)
 {
        struct skcipher_request *req = container_of(areq, struct 
skcipher_request, base);
        struct omap_aes_ctx *ctx = crypto_skcipher_ctx(
@@ -632,7 +632,7 @@ static int omap_aes_ctr_decrypt(struct skcipher_request 
*req)
 }
 
 static int omap_aes_prepare_req(struct crypto_engine *engine,
-                               void *req);
+                               void *req, int slot);
 static int omap_aes_crypt_req(struct crypto_engine *engine,
                              void *req);
 
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index 8eda43319204..92c5fb1d4b83 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -524,7 +524,7 @@ static int omap_des_handle_queue(struct omap_des_dev *dd,
 }
 
 static int omap_des_prepare_req(struct crypto_engine *engine,
-                               void *areq)
+                               void *areq, int slot)
 {
        struct skcipher_request *req = container_of(areq, struct 
skcipher_request, base);
        struct omap_des_ctx *ctx = crypto_skcipher_ctx(
@@ -711,7 +711,7 @@ static int omap_des_cbc_decrypt(struct skcipher_request 
*req)
 }
 
 static int omap_des_prepare_req(struct crypto_engine *engine,
-                               void *areq);
+                               void *areq, int slot);
 static int omap_des_crypt_req(struct crypto_engine *engine,
                              void *areq);
 
diff --git a/drivers/crypto/stm32/stm32-cryp.c 
b/drivers/crypto/stm32/stm32-cryp.c
index d347a1d6e351..7c65b526d20e 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -684,7 +684,7 @@ static int stm32_cryp_cpu_start(struct stm32_cryp *cryp)
 
 static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq);
 static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine,
-                                        void *areq);
+                                        void *areq, int slot);
 
 static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm)
 {
@@ -700,7 +700,7 @@ static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm)
 
 static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq);
 static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine,
-                                      void *areq);
+                                      void *areq, int slot);
 
 static int stm32_cryp_aes_aead_init(struct crypto_aead *tfm)
 {
@@ -1015,7 +1015,7 @@ static int stm32_cryp_prepare_req(struct skcipher_request 
*req,
 }
 
 static int stm32_cryp_prepare_cipher_req(struct crypto_engine *engine,
-                                        void *areq)
+                                        void *areq, int slot)
 {
        struct skcipher_request *req = container_of(areq,
                                                      struct skcipher_request,
@@ -1039,7 +1039,7 @@ static int stm32_cryp_cipher_one_req(struct crypto_engine 
*engine, void *areq)
        return stm32_cryp_cpu_start(cryp);
 }
 
-static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine, void 
*areq)
+static int stm32_cryp_prepare_aead_req(struct crypto_engine *engine, void 
*areq, int slot)
 {
        struct aead_request *req = container_of(areq, struct aead_request,
                                                base);
diff --git a/drivers/crypto/stm32/stm32-hash.c 
b/drivers/crypto/stm32/stm32-hash.c
index 167b80eec437..4a696c48126c 100644
--- a/drivers/crypto/stm32/stm32-hash.c
+++ b/drivers/crypto/stm32/stm32-hash.c
@@ -824,7 +824,7 @@ static int stm32_hash_hw_init(struct stm32_hash_dev *hdev,
 }
 
 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_prepare_req(struct crypto_engine *engine, void *areq, 
int slot);
 
 static int stm32_hash_handle_queue(struct stm32_hash_dev *hdev,
                                   struct ahash_request *req)
@@ -832,7 +832,7 @@ static int stm32_hash_handle_queue(struct stm32_hash_dev 
*hdev,
        return crypto_transfer_hash_request_to_engine(hdev->engine, req);
 }
 
-static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq)
+static int stm32_hash_prepare_req(struct crypto_engine *engine, void *areq, 
int slot)
 {
        struct ahash_request *req = container_of(areq, struct ahash_request,
                                                 base);
diff --git a/include/crypto/engine.h b/include/crypto/engine.h
index 021136a47b93..55d3dbc2498c 100644
--- a/include/crypto/engine.h
+++ b/include/crypto/engine.h
@@ -85,9 +85,9 @@ struct crypto_engine {
  */
 struct crypto_engine_op {
        int (*prepare_request)(struct crypto_engine *engine,
-                              void *areq);
+                              void *areq, int slot);
        int (*unprepare_request)(struct crypto_engine *engine,
-                                void *areq);
+                                void *areq, int slot);
        int (*do_one_request)(struct crypto_engine *engine,
                              void *areq);
 };
-- 
2.24.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200114135936.32422-9-clabbe.montjoie%40gmail.com.

Reply via email to