crypto: mediatek - move mtk_aes_find_dev() to the right place
Move mtk_aes_find_dev() to right functions as nobody uses the 'cryp' under current flows. We can also avoid duplicate checks here and there in this way. Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Vic Wu <vic.wu@mediatek.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
1bbbbcfdc0
commit
4797f6cab5
@ -651,14 +651,19 @@ static int mtk_aes_setkey(struct crypto_ablkcipher *tfm,
|
|||||||
|
|
||||||
static int mtk_aes_crypt(struct ablkcipher_request *req, u64 mode)
|
static int mtk_aes_crypt(struct ablkcipher_request *req, u64 mode)
|
||||||
{
|
{
|
||||||
struct mtk_aes_base_ctx *ctx;
|
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
|
||||||
|
struct mtk_aes_base_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
|
||||||
struct mtk_aes_reqctx *rctx;
|
struct mtk_aes_reqctx *rctx;
|
||||||
|
struct mtk_cryp *cryp;
|
||||||
|
|
||||||
|
cryp = mtk_aes_find_dev(ctx);
|
||||||
|
if (!cryp)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
ctx = crypto_ablkcipher_ctx(crypto_ablkcipher_reqtfm(req));
|
|
||||||
rctx = ablkcipher_request_ctx(req);
|
rctx = ablkcipher_request_ctx(req);
|
||||||
rctx->mode = mode;
|
rctx->mode = mode;
|
||||||
|
|
||||||
return mtk_aes_handle_queue(ctx->cryp, !(mode & AES_FLAGS_ENCRYPT),
|
return mtk_aes_handle_queue(cryp, !(mode & AES_FLAGS_ENCRYPT),
|
||||||
&req->base);
|
&req->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,13 +700,6 @@ static int mtk_aes_ctr_decrypt(struct ablkcipher_request *req)
|
|||||||
static int mtk_aes_cra_init(struct crypto_tfm *tfm)
|
static int mtk_aes_cra_init(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
struct mtk_aes_ctx *ctx = crypto_tfm_ctx(tfm);
|
struct mtk_aes_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||||
struct mtk_cryp *cryp = NULL;
|
|
||||||
|
|
||||||
cryp = mtk_aes_find_dev(&ctx->base);
|
|
||||||
if (!cryp) {
|
|
||||||
pr_err("can't find crypto device\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfm->crt_ablkcipher.reqsize = sizeof(struct mtk_aes_reqctx);
|
tfm->crt_ablkcipher.reqsize = sizeof(struct mtk_aes_reqctx);
|
||||||
ctx->base.start = mtk_aes_start;
|
ctx->base.start = mtk_aes_start;
|
||||||
@ -711,13 +709,6 @@ static int mtk_aes_cra_init(struct crypto_tfm *tfm)
|
|||||||
static int mtk_aes_ctr_cra_init(struct crypto_tfm *tfm)
|
static int mtk_aes_ctr_cra_init(struct crypto_tfm *tfm)
|
||||||
{
|
{
|
||||||
struct mtk_aes_ctx *ctx = crypto_tfm_ctx(tfm);
|
struct mtk_aes_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||||
struct mtk_cryp *cryp = NULL;
|
|
||||||
|
|
||||||
cryp = mtk_aes_find_dev(&ctx->base);
|
|
||||||
if (!cryp) {
|
|
||||||
pr_err("can't find crypto device\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
tfm->crt_ablkcipher.reqsize = sizeof(struct mtk_aes_reqctx);
|
tfm->crt_ablkcipher.reqsize = sizeof(struct mtk_aes_reqctx);
|
||||||
ctx->base.start = mtk_aes_ctr_start;
|
ctx->base.start = mtk_aes_ctr_start;
|
||||||
@ -923,6 +914,11 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode)
|
|||||||
struct mtk_aes_base_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
|
struct mtk_aes_base_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
|
||||||
struct mtk_aes_gcm_ctx *gctx = mtk_aes_gcm_ctx_cast(ctx);
|
struct mtk_aes_gcm_ctx *gctx = mtk_aes_gcm_ctx_cast(ctx);
|
||||||
struct mtk_aes_reqctx *rctx = aead_request_ctx(req);
|
struct mtk_aes_reqctx *rctx = aead_request_ctx(req);
|
||||||
|
struct mtk_cryp *cryp;
|
||||||
|
|
||||||
|
cryp = mtk_aes_find_dev(ctx);
|
||||||
|
if (!cryp)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
/* Empty messages are not supported yet */
|
/* Empty messages are not supported yet */
|
||||||
if (!gctx->textlen && !req->assoclen)
|
if (!gctx->textlen && !req->assoclen)
|
||||||
@ -930,7 +926,7 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode)
|
|||||||
|
|
||||||
rctx->mode = AES_FLAGS_GCM | mode;
|
rctx->mode = AES_FLAGS_GCM | mode;
|
||||||
|
|
||||||
return mtk_aes_handle_queue(ctx->cryp, !!(mode & AES_FLAGS_ENCRYPT),
|
return mtk_aes_handle_queue(cryp, !!(mode & AES_FLAGS_ENCRYPT),
|
||||||
&req->base);
|
&req->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1046,13 +1042,6 @@ static int mtk_aes_gcm_decrypt(struct aead_request *req)
|
|||||||
static int mtk_aes_gcm_init(struct crypto_aead *aead)
|
static int mtk_aes_gcm_init(struct crypto_aead *aead)
|
||||||
{
|
{
|
||||||
struct mtk_aes_gcm_ctx *ctx = crypto_aead_ctx(aead);
|
struct mtk_aes_gcm_ctx *ctx = crypto_aead_ctx(aead);
|
||||||
struct mtk_cryp *cryp = NULL;
|
|
||||||
|
|
||||||
cryp = mtk_aes_find_dev(&ctx->base);
|
|
||||||
if (!cryp) {
|
|
||||||
pr_err("can't find crypto device\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->ctr = crypto_alloc_skcipher("ctr(aes)", 0,
|
ctx->ctr = crypto_alloc_skcipher("ctr(aes)", 0,
|
||||||
CRYPTO_ALG_ASYNC);
|
CRYPTO_ALG_ASYNC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user