]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: sun8i-ce - pass task descriptor to cipher prepare/unprepare
authorOvidiu Panait <ovidiu.panait.oss@gmail.com>
Tue, 2 Sep 2025 13:21:32 +0000 (16:21 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 13 Sep 2025 04:11:05 +0000 (12:11 +0800)
To remove some duplicated code, directly pass 'struct skcipher_request' and
'struct ce_task' pointers to sun8i_ce_cipher_{prepare,unprepare}.

Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c

index f63d21cd1e52e75c3bf68aeab8ce47bf764db9ce..021614b65e39df9b425f9670a9da9f2e92e65089 100644 (file)
@@ -131,21 +131,19 @@ 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 skcipher_request *areq,
+                                  struct ce_task *cet)
 {
-       struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
        struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
        struct sun8i_ce_dev *ce = op->ce;
        struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
        struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
        struct sun8i_ce_alg_template *algt;
-       struct sun8i_ce_flow *chan;
-       struct ce_task *cet;
        struct scatterlist *sg;
        unsigned int todo, len, offset, ivsize;
        u32 common, sym;
-       int flow, i;
+       int i;
        int nr_sgs = 0;
        int nr_sgd = 0;
        int err = 0;
@@ -163,14 +161,9 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req
        if (IS_ENABLED(CONFIG_CRYPTO_DEV_SUN8I_CE_DEBUG))
                algt->stat_req++;
 
-       flow = rctx->flow;
-
-       chan = &ce->chanlist[flow];
-
-       cet = chan->tl;
        memset(cet, 0, sizeof(struct ce_task));
 
-       cet->t_id = cpu_to_le32(flow);
+       cet->t_id = cpu_to_le32(rctx->flow);
        common = ce->variant->alg_cipher[algt->ce_algo_id];
        common |= rctx->op_dir | CE_COMM_INT;
        cet->t_common_ctl = cpu_to_le32(common);
@@ -314,24 +307,17 @@ theend:
        return err;
 }
 
-static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
-                                     void *async_req)
+static void sun8i_ce_cipher_unprepare(struct skcipher_request *areq,
+                                     struct ce_task *cet)
 {
-       struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
        struct sun8i_cipher_tfm_ctx *op = crypto_skcipher_ctx(tfm);
        struct sun8i_ce_dev *ce = op->ce;
        struct sun8i_cipher_req_ctx *rctx = skcipher_request_ctx(areq);
-       struct sun8i_ce_flow *chan;
-       struct ce_task *cet;
        unsigned int ivsize, offset;
        int nr_sgs = rctx->nr_sgs;
        int nr_sgd = rctx->nr_sgd;
-       int flow;
 
-       flow = rctx->flow;
-       chan = &ce->chanlist[flow];
-       cet = chan->tl;
        ivsize = crypto_skcipher_ivsize(tfm);
 
        if (areq->src == areq->dst) {
@@ -367,16 +353,19 @@ int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq)
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
        struct sun8i_cipher_tfm_ctx *ctx = crypto_skcipher_ctx(tfm);
        struct sun8i_ce_dev *ce = ctx->ce;
+       struct sun8i_ce_flow *chan;
        int err;
 
-       err = sun8i_ce_cipher_prepare(engine, areq);
+       chan = &ce->chanlist[rctx->flow];
+
+       err = sun8i_ce_cipher_prepare(req, chan->tl);
        if (err)
                return err;
 
        err = sun8i_ce_run_task(ce, rctx->flow,
                                crypto_tfm_alg_name(req->base.tfm));
 
-       sun8i_ce_cipher_unprepare(engine, areq);
+       sun8i_ce_cipher_unprepare(req, chan->tl);
 
        local_bh_disable();
        crypto_finalize_skcipher_request(engine, req, err);