Skip to content

Commit

Permalink
crypto: sun8i-ce - Remove prepare/unprepare request
Browse files Browse the repository at this point in the history
The callbacks for prepare and unprepare request in crypto_engine
is superfluous.  They can be done directly from do_one_request.

Move the code into do_one_request and remove the unused callbacks.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
herbertx committed Aug 18, 2023
1 parent cdb8b7e commit 4136212
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 14 additions & 6 deletions drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req
return err;
}

static int sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq)
static void sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq)
{
struct skcipher_request *breq = container_of(areq, struct skcipher_request, base);
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(breq);
Expand All @@ -308,10 +308,10 @@ static int sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq)
local_bh_disable();
crypto_finalize_skcipher_request(engine, breq, err);
local_bh_enable();
return 0;
}

static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_req)
static void sun8i_ce_cipher_unprepare(struct crypto_engine *engine,
void *async_req)
{
struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
Expand Down Expand Up @@ -353,7 +353,17 @@ static int sun8i_ce_cipher_unprepare(struct crypto_engine *engine, void *async_r
}

dma_unmap_single(ce->dev, rctx->addr_key, op->keylen, DMA_TO_DEVICE);
}

static int sun8i_ce_cipher_do_one(struct crypto_engine *engine, void *areq)
{
int err = sun8i_ce_cipher_prepare(engine, areq);

if (err)
return err;

sun8i_ce_cipher_run(engine, areq);
sun8i_ce_cipher_unprepare(engine, areq);
return 0;
}

Expand Down Expand Up @@ -423,9 +433,7 @@ int sun8i_ce_cipher_init(struct crypto_tfm *tfm)
crypto_tfm_alg_driver_name(crypto_skcipher_tfm(op->fallback_tfm)),
CRYPTO_MAX_ALG_NAME);

op->enginectx.op.do_one_request = sun8i_ce_cipher_run;
op->enginectx.op.prepare_request = sun8i_ce_cipher_prepare;
op->enginectx.op.unprepare_request = sun8i_ce_cipher_unprepare;
op->enginectx.op.do_one_request = sun8i_ce_cipher_do_one;

err = pm_runtime_get_sync(op->ce->dev);
if (err < 0)
Expand Down
2 changes: 0 additions & 2 deletions drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ int sun8i_ce_hash_crainit(struct crypto_tfm *tfm)
op->ce = algt->ce;

op->enginectx.op.do_one_request = sun8i_ce_hash_run;
op->enginectx.op.prepare_request = NULL;
op->enginectx.op.unprepare_request = NULL;

/* FALLBACK */
op->fallback_tfm = crypto_alloc_ahash(crypto_tfm_alg_name(tfm), 0,
Expand Down

0 comments on commit 4136212

Please sign in to comment.