Commit 2e3b1495 authored by Corentin Labbe's avatar Corentin Labbe Committed by Herbert Xu

crypto: rockchip - rework rk_handle_req function

This patch rework the rk_handle_req(), simply removing the
rk_crypto_info parameter.
Reviewed-by: default avatarJohn Keeping <john@metanate.com>
Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a7fa0644
...@@ -82,10 +82,12 @@ static int rk_cipher_fallback(struct skcipher_request *areq) ...@@ -82,10 +82,12 @@ static int rk_cipher_fallback(struct skcipher_request *areq)
return err; return err;
} }
static int rk_handle_req(struct rk_crypto_info *dev, static int rk_cipher_handle_req(struct skcipher_request *req)
struct skcipher_request *req)
{ {
struct crypto_engine *engine = dev->engine; struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *tctx = crypto_skcipher_ctx(tfm);
struct rk_crypto_info *rkc = tctx->dev;
struct crypto_engine *engine = rkc->engine;
if (rk_cipher_need_fallback(req)) if (rk_cipher_need_fallback(req))
return rk_cipher_fallback(req); return rk_cipher_fallback(req);
...@@ -142,135 +144,99 @@ static int rk_tdes_setkey(struct crypto_skcipher *cipher, ...@@ -142,135 +144,99 @@ static int rk_tdes_setkey(struct crypto_skcipher *cipher,
static int rk_aes_ecb_encrypt(struct skcipher_request *req) static int rk_aes_ecb_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_AES_ECB_MODE; rctx->mode = RK_CRYPTO_AES_ECB_MODE;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_aes_ecb_decrypt(struct skcipher_request *req) static int rk_aes_ecb_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_AES_ECB_MODE | RK_CRYPTO_DEC; rctx->mode = RK_CRYPTO_AES_ECB_MODE | RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_aes_cbc_encrypt(struct skcipher_request *req) static int rk_aes_cbc_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_AES_CBC_MODE; rctx->mode = RK_CRYPTO_AES_CBC_MODE;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_aes_cbc_decrypt(struct skcipher_request *req) static int rk_aes_cbc_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_AES_CBC_MODE | RK_CRYPTO_DEC; rctx->mode = RK_CRYPTO_AES_CBC_MODE | RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des_ecb_encrypt(struct skcipher_request *req) static int rk_des_ecb_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = 0; rctx->mode = 0;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des_ecb_decrypt(struct skcipher_request *req) static int rk_des_ecb_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_DEC; rctx->mode = RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des_cbc_encrypt(struct skcipher_request *req) static int rk_des_cbc_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_CHAINMODE_CBC; rctx->mode = RK_CRYPTO_TDES_CHAINMODE_CBC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des_cbc_decrypt(struct skcipher_request *req) static int rk_des_cbc_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_CHAINMODE_CBC | RK_CRYPTO_DEC; rctx->mode = RK_CRYPTO_TDES_CHAINMODE_CBC | RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des3_ede_ecb_encrypt(struct skcipher_request *req) static int rk_des3_ede_ecb_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_SELECT; rctx->mode = RK_CRYPTO_TDES_SELECT;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des3_ede_ecb_decrypt(struct skcipher_request *req) static int rk_des3_ede_ecb_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_DEC; rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des3_ede_cbc_encrypt(struct skcipher_request *req) static int rk_des3_ede_cbc_encrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_TDES_CHAINMODE_CBC; rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_TDES_CHAINMODE_CBC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static int rk_des3_ede_cbc_decrypt(struct skcipher_request *req) static int rk_des3_ede_cbc_decrypt(struct skcipher_request *req)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
struct rk_cipher_rctx *rctx = skcipher_request_ctx(req); struct rk_cipher_rctx *rctx = skcipher_request_ctx(req);
struct rk_crypto_info *dev = ctx->dev;
rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_TDES_CHAINMODE_CBC | rctx->mode = RK_CRYPTO_TDES_SELECT | RK_CRYPTO_TDES_CHAINMODE_CBC |
RK_CRYPTO_DEC; RK_CRYPTO_DEC;
return rk_handle_req(dev, req); return rk_cipher_handle_req(req);
} }
static void rk_cipher_hw_init(struct rk_crypto_info *dev, struct skcipher_request *req) static void rk_cipher_hw_init(struct rk_crypto_info *dev, struct skcipher_request *req)
......
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