diff options
-rw-r--r-- | drivers/crypto/talitos.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index a0d4a08313ae..35198804d6d3 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
@@ -2629,21 +2629,11 @@ struct talitos_crypto_alg { | |||
2629 | struct talitos_alg_template algt; | 2629 | struct talitos_alg_template algt; |
2630 | }; | 2630 | }; |
2631 | 2631 | ||
2632 | static int talitos_cra_init(struct crypto_tfm *tfm) | 2632 | static int talitos_init_common(struct talitos_ctx *ctx, |
2633 | struct talitos_crypto_alg *talitos_alg) | ||
2633 | { | 2634 | { |
2634 | struct crypto_alg *alg = tfm->__crt_alg; | ||
2635 | struct talitos_crypto_alg *talitos_alg; | ||
2636 | struct talitos_ctx *ctx = crypto_tfm_ctx(tfm); | ||
2637 | struct talitos_private *priv; | 2635 | struct talitos_private *priv; |
2638 | 2636 | ||
2639 | if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH) | ||
2640 | talitos_alg = container_of(__crypto_ahash_alg(alg), | ||
2641 | struct talitos_crypto_alg, | ||
2642 | algt.alg.hash); | ||
2643 | else | ||
2644 | talitos_alg = container_of(alg, struct talitos_crypto_alg, | ||
2645 | algt.alg.crypto); | ||
2646 | |||
2647 | /* update context with ptr to dev */ | 2637 | /* update context with ptr to dev */ |
2648 | ctx->dev = talitos_alg->dev; | 2638 | ctx->dev = talitos_alg->dev; |
2649 | 2639 | ||
@@ -2661,10 +2651,33 @@ static int talitos_cra_init(struct crypto_tfm *tfm) | |||
2661 | return 0; | 2651 | return 0; |
2662 | } | 2652 | } |
2663 | 2653 | ||
2654 | static int talitos_cra_init(struct crypto_tfm *tfm) | ||
2655 | { | ||
2656 | struct crypto_alg *alg = tfm->__crt_alg; | ||
2657 | struct talitos_crypto_alg *talitos_alg; | ||
2658 | struct talitos_ctx *ctx = crypto_tfm_ctx(tfm); | ||
2659 | |||
2660 | if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH) | ||
2661 | talitos_alg = container_of(__crypto_ahash_alg(alg), | ||
2662 | struct talitos_crypto_alg, | ||
2663 | algt.alg.hash); | ||
2664 | else | ||
2665 | talitos_alg = container_of(alg, struct talitos_crypto_alg, | ||
2666 | algt.alg.crypto); | ||
2667 | |||
2668 | return talitos_init_common(ctx, talitos_alg); | ||
2669 | } | ||
2670 | |||
2664 | static int talitos_cra_init_aead(struct crypto_aead *tfm) | 2671 | static int talitos_cra_init_aead(struct crypto_aead *tfm) |
2665 | { | 2672 | { |
2666 | talitos_cra_init(crypto_aead_tfm(tfm)); | 2673 | struct aead_alg *alg = crypto_aead_alg(tfm); |
2667 | return 0; | 2674 | struct talitos_crypto_alg *talitos_alg; |
2675 | struct talitos_ctx *ctx = crypto_aead_ctx(tfm); | ||
2676 | |||
2677 | talitos_alg = container_of(alg, struct talitos_crypto_alg, | ||
2678 | algt.alg.aead); | ||
2679 | |||
2680 | return talitos_init_common(ctx, talitos_alg); | ||
2668 | } | 2681 | } |
2669 | 2682 | ||
2670 | static int talitos_cra_init_ahash(struct crypto_tfm *tfm) | 2683 | static int talitos_cra_init_ahash(struct crypto_tfm *tfm) |