66 *
77 * Core file which registers crypto algorithms supported by the hardware.
88 */
9+
10+ #include <crypto/engine.h>
11+ #include <crypto/internal/skcipher.h>
912#include <linux/clk.h>
10- #include <linux/crypto .h>
11- #include <linux/io .h>
13+ #include <linux/dma-mapping .h>
14+ #include <linux/err .h>
1215#include <linux/interrupt.h>
16+ #include <linux/io.h>
1317#include <linux/irq.h>
18+ #include <linux/kernel.h>
1419#include <linux/module.h>
1520#include <linux/of.h>
1621#include <linux/of_device.h>
1722#include <linux/platform_device.h>
18- #include <crypto/internal/skcipher.h>
19- #include <linux/dma-mapping.h>
2023
2124#include "amlogic-gxl.h"
2225
@@ -47,7 +50,7 @@ static struct meson_alg_template mc_algs[] = {
4750{
4851 .type = CRYPTO_ALG_TYPE_SKCIPHER ,
4952 .blockmode = MESON_OPMODE_CBC ,
50- .alg .skcipher = {
53+ .alg .skcipher . base = {
5154 .base = {
5255 .cra_name = "cbc(aes)" ,
5356 .cra_driver_name = "cbc-aes-gxl" ,
@@ -68,12 +71,15 @@ static struct meson_alg_template mc_algs[] = {
6871 .setkey = meson_aes_setkey ,
6972 .encrypt = meson_skencrypt ,
7073 .decrypt = meson_skdecrypt ,
71- }
74+ },
75+ .alg .skcipher .op = {
76+ .do_one_request = meson_handle_cipher_request ,
77+ },
7278},
7379{
7480 .type = CRYPTO_ALG_TYPE_SKCIPHER ,
7581 .blockmode = MESON_OPMODE_ECB ,
76- .alg .skcipher = {
82+ .alg .skcipher . base = {
7783 .base = {
7884 .cra_name = "ecb(aes)" ,
7985 .cra_driver_name = "ecb-aes-gxl" ,
@@ -93,33 +99,43 @@ static struct meson_alg_template mc_algs[] = {
9399 .setkey = meson_aes_setkey ,
94100 .encrypt = meson_skencrypt ,
95101 .decrypt = meson_skdecrypt ,
96- }
102+ },
103+ .alg .skcipher .op = {
104+ .do_one_request = meson_handle_cipher_request ,
105+ },
97106},
98107};
99108
100- #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG
101109static int meson_debugfs_show (struct seq_file * seq , void * v )
102110{
103- struct meson_dev * mc = seq -> private ;
111+ struct meson_dev * mc __maybe_unused = seq -> private ;
104112 int i ;
105113
106114 for (i = 0 ; i < MAXFLOW ; i ++ )
107- seq_printf (seq , "Channel %d: nreq %lu\n" , i , mc -> chanlist [i ].stat_req );
115+ seq_printf (seq , "Channel %d: nreq %lu\n" , i ,
116+ #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG
117+ mc -> chanlist [i ].stat_req );
118+ #else
119+ 0ul );
120+ #endif
108121
109122 for (i = 0 ; i < ARRAY_SIZE (mc_algs ); i ++ ) {
110123 switch (mc_algs [i ].type ) {
111124 case CRYPTO_ALG_TYPE_SKCIPHER :
112125 seq_printf (seq , "%s %s %lu %lu\n" ,
113- mc_algs [i ].alg .skcipher .base .cra_driver_name ,
114- mc_algs [i ].alg .skcipher .base .cra_name ,
126+ mc_algs [i ].alg .skcipher .base .base .cra_driver_name ,
127+ mc_algs [i ].alg .skcipher .base .base .cra_name ,
128+ #ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG
115129 mc_algs [i ].stat_req , mc_algs [i ].stat_fb );
130+ #else
131+ 0ul , 0ul );
132+ #endif
116133 break ;
117134 }
118135 }
119136 return 0 ;
120137}
121138DEFINE_SHOW_ATTRIBUTE (meson_debugfs );
122- #endif
123139
124140static void meson_free_chanlist (struct meson_dev * mc , int i )
125141{
@@ -183,10 +199,10 @@ static int meson_register_algs(struct meson_dev *mc)
183199 mc_algs [i ].mc = mc ;
184200 switch (mc_algs [i ].type ) {
185201 case CRYPTO_ALG_TYPE_SKCIPHER :
186- err = crypto_register_skcipher (& mc_algs [i ].alg .skcipher );
202+ err = crypto_engine_register_skcipher (& mc_algs [i ].alg .skcipher );
187203 if (err ) {
188204 dev_err (mc -> dev , "Fail to register %s\n" ,
189- mc_algs [i ].alg .skcipher .base .cra_name );
205+ mc_algs [i ].alg .skcipher .base .base . cra_name );
190206 mc_algs [i ].mc = NULL ;
191207 return err ;
192208 }
@@ -206,7 +222,7 @@ static void meson_unregister_algs(struct meson_dev *mc)
206222 continue ;
207223 switch (mc_algs [i ].type ) {
208224 case CRYPTO_ALG_TYPE_SKCIPHER :
209- crypto_unregister_skcipher (& mc_algs [i ].alg .skcipher );
225+ crypto_engine_unregister_skcipher (& mc_algs [i ].alg .skcipher );
210226 break ;
211227 }
212228 }
@@ -264,10 +280,16 @@ static int meson_crypto_probe(struct platform_device *pdev)
264280 if (err )
265281 goto error_alg ;
266282
283+ if (IS_ENABLED (CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG )) {
284+ struct dentry * dbgfs_dir ;
285+
286+ dbgfs_dir = debugfs_create_dir ("gxl-crypto" , NULL );
287+ debugfs_create_file ("stats" , 0444 , dbgfs_dir , mc , & meson_debugfs_fops );
288+
267289#ifdef CONFIG_CRYPTO_DEV_AMLOGIC_GXL_DEBUG
268- mc -> dbgfs_dir = debugfs_create_dir ("gxl-crypto" , NULL );
269- debugfs_create_file ("stats" , 0444 , mc -> dbgfs_dir , mc , & meson_debugfs_fops );
290+ mc -> dbgfs_dir = dbgfs_dir ;
270291#endif
292+ }
271293
272294 return 0 ;
273295error_alg :
0 commit comments