22/*
33 * Copyright 2021 Aspeed Technology Inc.
44 */
5- #include <crypto/akcipher.h>
6- #include <crypto/algapi.h>
75#include <crypto/engine.h>
86#include <crypto/internal/akcipher.h>
97#include <crypto/internal/rsa.h>
108#include <crypto/scatterwalk.h>
119#include <linux/clk.h>
12- #include <linux/platform_device.h>
10+ #include <linux/count_zeros.h>
11+ #include <linux/dma-mapping.h>
12+ #include <linux/err.h>
13+ #include <linux/interrupt.h>
14+ #include <linux/kernel.h>
15+ #include <linux/mfd/syscon.h>
1316#include <linux/module.h>
14- #include <linux/of_address.h>
15- #include <linux/of_irq.h>
1617#include <linux/of.h>
1718#include <linux/of_device.h>
18- #include <linux/mfd/syscon.h>
19- #include <linux/interrupt.h>
20- #include <linux/count_zeros.h>
21- #include <linux/err.h>
22- #include <linux/dma-mapping.h>
19+ #include <linux/of_address.h>
20+ #include <linux/of_irq.h>
21+ #include <linux/platform_device.h>
2322#include <linux/regmap.h>
23+ #include <linux/slab.h>
24+ #include <linux/string.h>
2425
2526#ifdef CONFIG_CRYPTO_DEV_ASPEED_DEBUG
2627#define ACRY_DBG (d , fmt , ...) \
@@ -112,7 +113,6 @@ struct aspeed_acry_dev {
112113};
113114
114115struct aspeed_acry_ctx {
115- struct crypto_engine_ctx enginectx ;
116116 struct aspeed_acry_dev * acry_dev ;
117117
118118 struct rsa_key key ;
@@ -131,7 +131,7 @@ struct aspeed_acry_ctx {
131131
132132struct aspeed_acry_alg {
133133 struct aspeed_acry_dev * acry_dev ;
134- struct akcipher_alg akcipher ;
134+ struct akcipher_engine_alg akcipher ;
135135};
136136
137137enum aspeed_rsa_key_mode {
@@ -577,7 +577,7 @@ static int aspeed_acry_rsa_init_tfm(struct crypto_akcipher *tfm)
577577 const char * name = crypto_tfm_alg_name (& tfm -> base );
578578 struct aspeed_acry_alg * acry_alg ;
579579
580- acry_alg = container_of (alg , struct aspeed_acry_alg , akcipher );
580+ acry_alg = container_of (alg , struct aspeed_acry_alg , akcipher . base );
581581
582582 ctx -> acry_dev = acry_alg -> acry_dev ;
583583
@@ -589,8 +589,6 @@ static int aspeed_acry_rsa_init_tfm(struct crypto_akcipher *tfm)
589589 return PTR_ERR (ctx -> fallback_tfm );
590590 }
591591
592- ctx -> enginectx .op .do_one_request = aspeed_acry_do_request ;
593-
594592 return 0 ;
595593}
596594
@@ -603,7 +601,7 @@ static void aspeed_acry_rsa_exit_tfm(struct crypto_akcipher *tfm)
603601
604602static struct aspeed_acry_alg aspeed_acry_akcipher_algs [] = {
605603 {
606- .akcipher = {
604+ .akcipher . base = {
607605 .encrypt = aspeed_acry_rsa_enc ,
608606 .decrypt = aspeed_acry_rsa_dec ,
609607 .sign = aspeed_acry_rsa_dec ,
@@ -625,6 +623,9 @@ static struct aspeed_acry_alg aspeed_acry_akcipher_algs[] = {
625623 .cra_ctxsize = sizeof (struct aspeed_acry_ctx ),
626624 },
627625 },
626+ .akcipher .op = {
627+ .do_one_request = aspeed_acry_do_request ,
628+ },
628629 },
629630};
630631
@@ -634,10 +635,10 @@ static void aspeed_acry_register(struct aspeed_acry_dev *acry_dev)
634635
635636 for (i = 0 ; i < ARRAY_SIZE (aspeed_acry_akcipher_algs ); i ++ ) {
636637 aspeed_acry_akcipher_algs [i ].acry_dev = acry_dev ;
637- rc = crypto_register_akcipher (& aspeed_acry_akcipher_algs [i ].akcipher );
638+ rc = crypto_engine_register_akcipher (& aspeed_acry_akcipher_algs [i ].akcipher );
638639 if (rc ) {
639640 ACRY_DBG (acry_dev , "Failed to register %s\n" ,
640- aspeed_acry_akcipher_algs [i ].akcipher .base .cra_name );
641+ aspeed_acry_akcipher_algs [i ].akcipher .base .base . cra_name );
641642 }
642643 }
643644}
@@ -647,7 +648,7 @@ static void aspeed_acry_unregister(struct aspeed_acry_dev *acry_dev)
647648 int i ;
648649
649650 for (i = 0 ; i < ARRAY_SIZE (aspeed_acry_akcipher_algs ); i ++ )
650- crypto_unregister_akcipher (& aspeed_acry_akcipher_algs [i ].akcipher );
651+ crypto_engine_unregister_akcipher (& aspeed_acry_akcipher_algs [i ].akcipher );
651652}
652653
653654/* ACRY interrupt service routine. */
0 commit comments