Commit c752c013 authored by Herbert Xu's avatar Herbert Xu

crypto: omap - Remove prepare/unprepare request

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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 08d81da7
...@@ -212,12 +212,10 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, ...@@ -212,12 +212,10 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd,
return 0; return 0;
} }
static int omap_aes_gcm_prepare_req(struct crypto_engine *engine, void *areq) static int omap_aes_gcm_prepare_req(struct aead_request *req,
struct omap_aes_dev *dd)
{ {
struct aead_request *req = container_of(areq, struct aead_request,
base);
struct omap_aes_reqctx *rctx = aead_request_ctx(req); struct omap_aes_reqctx *rctx = aead_request_ctx(req);
struct omap_aes_dev *dd = rctx->dd;
struct omap_aes_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); struct omap_aes_gcm_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
int err; int err;
...@@ -362,11 +360,15 @@ static int omap_aes_gcm_crypt_req(struct crypto_engine *engine, void *areq) ...@@ -362,11 +360,15 @@ static int omap_aes_gcm_crypt_req(struct crypto_engine *engine, void *areq)
base); base);
struct omap_aes_reqctx *rctx = aead_request_ctx(req); struct omap_aes_reqctx *rctx = aead_request_ctx(req);
struct omap_aes_dev *dd = rctx->dd; struct omap_aes_dev *dd = rctx->dd;
int ret = 0; int ret;
if (!dd) if (!dd)
return -ENODEV; return -ENODEV;
ret = omap_aes_gcm_prepare_req(req, dd);
if (ret)
return ret;
if (dd->in_sg_len) if (dd->in_sg_len)
ret = omap_aes_crypt_dma_start(dd); ret = omap_aes_crypt_dma_start(dd);
else else
...@@ -379,8 +381,6 @@ int omap_aes_gcm_cra_init(struct crypto_aead *tfm) ...@@ -379,8 +381,6 @@ int omap_aes_gcm_cra_init(struct crypto_aead *tfm)
{ {
struct omap_aes_ctx *ctx = crypto_aead_ctx(tfm); struct omap_aes_ctx *ctx = crypto_aead_ctx(tfm);
ctx->enginectx.op.prepare_request = omap_aes_gcm_prepare_req;
ctx->enginectx.op.unprepare_request = NULL;
ctx->enginectx.op.do_one_request = omap_aes_gcm_crypt_req; ctx->enginectx.op.do_one_request = omap_aes_gcm_crypt_req;
crypto_aead_set_reqsize(tfm, sizeof(struct omap_aes_reqctx)); crypto_aead_set_reqsize(tfm, sizeof(struct omap_aes_reqctx));
......
...@@ -426,20 +426,15 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd, ...@@ -426,20 +426,15 @@ static int omap_aes_handle_queue(struct omap_aes_dev *dd,
return 0; return 0;
} }
static int omap_aes_prepare_req(struct crypto_engine *engine, static int omap_aes_prepare_req(struct skcipher_request *req,
void *areq) struct omap_aes_dev *dd)
{ {
struct skcipher_request *req = container_of(areq, struct skcipher_request, base);
struct omap_aes_ctx *ctx = crypto_skcipher_ctx( struct omap_aes_ctx *ctx = crypto_skcipher_ctx(
crypto_skcipher_reqtfm(req)); crypto_skcipher_reqtfm(req));
struct omap_aes_reqctx *rctx = skcipher_request_ctx(req); struct omap_aes_reqctx *rctx = skcipher_request_ctx(req);
struct omap_aes_dev *dd = rctx->dd;
int ret; int ret;
u16 flags; u16 flags;
if (!dd)
return -ENODEV;
/* assign new request to device */ /* assign new request to device */
dd->req = req; dd->req = req;
dd->total = req->cryptlen; dd->total = req->cryptlen;
...@@ -491,7 +486,8 @@ static int omap_aes_crypt_req(struct crypto_engine *engine, ...@@ -491,7 +486,8 @@ static int omap_aes_crypt_req(struct crypto_engine *engine,
if (!dd) if (!dd)
return -ENODEV; return -ENODEV;
return omap_aes_crypt_dma_start(dd); return omap_aes_prepare_req(req, dd) ?:
omap_aes_crypt_dma_start(dd);
} }
static void omap_aes_copy_ivout(struct omap_aes_dev *dd, u8 *ivbuf) static void omap_aes_copy_ivout(struct omap_aes_dev *dd, u8 *ivbuf)
...@@ -629,11 +625,6 @@ static int omap_aes_ctr_decrypt(struct skcipher_request *req) ...@@ -629,11 +625,6 @@ static int omap_aes_ctr_decrypt(struct skcipher_request *req)
return omap_aes_crypt(req, FLAGS_CTR); return omap_aes_crypt(req, FLAGS_CTR);
} }
static int omap_aes_prepare_req(struct crypto_engine *engine,
void *req);
static int omap_aes_crypt_req(struct crypto_engine *engine,
void *req);
static int omap_aes_init_tfm(struct crypto_skcipher *tfm) static int omap_aes_init_tfm(struct crypto_skcipher *tfm)
{ {
const char *name = crypto_tfm_alg_name(&tfm->base); const char *name = crypto_tfm_alg_name(&tfm->base);
...@@ -649,8 +640,6 @@ static int omap_aes_init_tfm(struct crypto_skcipher *tfm) ...@@ -649,8 +640,6 @@ static int omap_aes_init_tfm(struct crypto_skcipher *tfm)
crypto_skcipher_set_reqsize(tfm, sizeof(struct omap_aes_reqctx) + crypto_skcipher_set_reqsize(tfm, sizeof(struct omap_aes_reqctx) +
crypto_skcipher_reqsize(blk)); crypto_skcipher_reqsize(blk));
ctx->enginectx.op.prepare_request = omap_aes_prepare_req;
ctx->enginectx.op.unprepare_request = NULL;
ctx->enginectx.op.do_one_request = omap_aes_crypt_req; ctx->enginectx.op.do_one_request = omap_aes_crypt_req;
return 0; return 0;
......
...@@ -522,20 +522,15 @@ static int omap_des_handle_queue(struct omap_des_dev *dd, ...@@ -522,20 +522,15 @@ static int omap_des_handle_queue(struct omap_des_dev *dd,
return 0; return 0;
} }
static int omap_des_prepare_req(struct crypto_engine *engine, static int omap_des_prepare_req(struct skcipher_request *req,
void *areq) struct omap_des_dev *dd)
{ {
struct skcipher_request *req = container_of(areq, struct skcipher_request, base);
struct omap_des_ctx *ctx = crypto_skcipher_ctx( struct omap_des_ctx *ctx = crypto_skcipher_ctx(
crypto_skcipher_reqtfm(req)); crypto_skcipher_reqtfm(req));
struct omap_des_dev *dd = omap_des_find_dev(ctx);
struct omap_des_reqctx *rctx; struct omap_des_reqctx *rctx;
int ret; int ret;
u16 flags; u16 flags;
if (!dd)
return -ENODEV;
/* assign new request to device */ /* assign new request to device */
dd->req = req; dd->req = req;
dd->total = req->cryptlen; dd->total = req->cryptlen;
...@@ -590,7 +585,8 @@ static int omap_des_crypt_req(struct crypto_engine *engine, ...@@ -590,7 +585,8 @@ static int omap_des_crypt_req(struct crypto_engine *engine,
if (!dd) if (!dd)
return -ENODEV; return -ENODEV;
return omap_des_crypt_dma_start(dd); return omap_des_prepare_req(req, dd) ?:
omap_des_crypt_dma_start(dd);
} }
static void omap_des_done_task(unsigned long data) static void omap_des_done_task(unsigned long data)
...@@ -709,11 +705,6 @@ static int omap_des_cbc_decrypt(struct skcipher_request *req) ...@@ -709,11 +705,6 @@ static int omap_des_cbc_decrypt(struct skcipher_request *req)
return omap_des_crypt(req, FLAGS_CBC); return omap_des_crypt(req, FLAGS_CBC);
} }
static int omap_des_prepare_req(struct crypto_engine *engine,
void *areq);
static int omap_des_crypt_req(struct crypto_engine *engine,
void *areq);
static int omap_des_init_tfm(struct crypto_skcipher *tfm) static int omap_des_init_tfm(struct crypto_skcipher *tfm)
{ {
struct omap_des_ctx *ctx = crypto_skcipher_ctx(tfm); struct omap_des_ctx *ctx = crypto_skcipher_ctx(tfm);
...@@ -722,8 +713,6 @@ static int omap_des_init_tfm(struct crypto_skcipher *tfm) ...@@ -722,8 +713,6 @@ static int omap_des_init_tfm(struct crypto_skcipher *tfm)
crypto_skcipher_set_reqsize(tfm, sizeof(struct omap_des_reqctx)); crypto_skcipher_set_reqsize(tfm, sizeof(struct omap_des_reqctx));
ctx->enginectx.op.prepare_request = omap_des_prepare_req;
ctx->enginectx.op.unprepare_request = NULL;
ctx->enginectx.op.do_one_request = omap_des_crypt_req; ctx->enginectx.op.do_one_request = omap_des_crypt_req;
return 0; return 0;
......
...@@ -1074,6 +1074,10 @@ static int omap_sham_hash_one_req(struct crypto_engine *engine, void *areq) ...@@ -1074,6 +1074,10 @@ static int omap_sham_hash_one_req(struct crypto_engine *engine, void *areq)
dev_dbg(dd->dev, "hash-one: op: %u, total: %u, digcnt: %zd, final: %d", dev_dbg(dd->dev, "hash-one: op: %u, total: %u, digcnt: %zd, final: %d",
ctx->op, ctx->total, ctx->digcnt, final); ctx->op, ctx->total, ctx->digcnt, final);
err = omap_sham_prepare_request(engine, areq);
if (err)
return err;
err = pm_runtime_resume_and_get(dd->dev); err = pm_runtime_resume_and_get(dd->dev);
if (err < 0) { if (err < 0) {
dev_err(dd->dev, "failed to get sync: %d\n", err); dev_err(dd->dev, "failed to get sync: %d\n", err);
...@@ -1350,8 +1354,6 @@ static int omap_sham_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base) ...@@ -1350,8 +1354,6 @@ static int omap_sham_cra_init_alg(struct crypto_tfm *tfm, const char *alg_base)
} }
tctx->enginectx.op.do_one_request = omap_sham_hash_one_req; tctx->enginectx.op.do_one_request = omap_sham_hash_one_req;
tctx->enginectx.op.prepare_request = omap_sham_prepare_request;
tctx->enginectx.op.unprepare_request = NULL;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment