66 *
77 * Core file which registers crypto algorithms supported by the CryptoEngine
88 */
9+
10+ #include <crypto/engine.h>
11+ #include <crypto/internal/rng.h>
12+ #include <crypto/internal/skcipher.h>
913#include <linux/clk.h>
10- #include <linux/crypto.h>
1114#include <linux/debugfs.h>
1215#include <linux/dev_printk.h>
1316#include <linux/dma-mapping.h>
17+ #include <linux/err.h>
1418#include <linux/interrupt.h>
1519#include <linux/io.h>
1620#include <linux/irq.h>
21+ #include <linux/kernel.h>
1722#include <linux/module.h>
1823#include <linux/of.h>
1924#include <linux/of_device.h>
2025#include <linux/platform_device.h>
2126#include <linux/pm_runtime.h>
2227#include <linux/reset.h>
23- #include <crypto/internal/rng.h>
24- #include <crypto/internal/skcipher.h>
2528
2629#include "sl3516-ce.h"
2730
@@ -217,7 +220,7 @@ static struct sl3516_ce_alg_template ce_algs[] = {
217220{
218221 .type = CRYPTO_ALG_TYPE_SKCIPHER ,
219222 .mode = ECB_AES ,
220- .alg .skcipher = {
223+ .alg .skcipher . base = {
221224 .base = {
222225 .cra_name = "ecb(aes)" ,
223226 .cra_driver_name = "ecb-aes-sl3516" ,
@@ -236,11 +239,13 @@ static struct sl3516_ce_alg_template ce_algs[] = {
236239 .setkey = sl3516_ce_aes_setkey ,
237240 .encrypt = sl3516_ce_skencrypt ,
238241 .decrypt = sl3516_ce_skdecrypt ,
239- }
242+ },
243+ .alg .skcipher .op = {
244+ .do_one_request = sl3516_ce_handle_cipher_request ,
245+ },
240246},
241247};
242248
243- #ifdef CONFIG_CRYPTO_DEV_SL3516_DEBUG
244249static int sl3516_ce_debugfs_show (struct seq_file * seq , void * v )
245250{
246251 struct sl3516_ce_dev * ce = seq -> private ;
@@ -264,8 +269,8 @@ static int sl3516_ce_debugfs_show(struct seq_file *seq, void *v)
264269 switch (ce_algs [i ].type ) {
265270 case CRYPTO_ALG_TYPE_SKCIPHER :
266271 seq_printf (seq , "%s %s reqs=%lu fallback=%lu\n" ,
267- ce_algs [i ].alg .skcipher .base .cra_driver_name ,
268- ce_algs [i ].alg .skcipher .base .cra_name ,
272+ ce_algs [i ].alg .skcipher .base .base . cra_driver_name ,
273+ ce_algs [i ].alg .skcipher .base .base . cra_name ,
269274 ce_algs [i ].stat_req , ce_algs [i ].stat_fb );
270275 break ;
271276 }
@@ -274,7 +279,6 @@ static int sl3516_ce_debugfs_show(struct seq_file *seq, void *v)
274279}
275280
276281DEFINE_SHOW_ATTRIBUTE (sl3516_ce_debugfs );
277- #endif
278282
279283static int sl3516_ce_register_algs (struct sl3516_ce_dev * ce )
280284{
@@ -286,11 +290,11 @@ static int sl3516_ce_register_algs(struct sl3516_ce_dev *ce)
286290 switch (ce_algs [i ].type ) {
287291 case CRYPTO_ALG_TYPE_SKCIPHER :
288292 dev_info (ce -> dev , "DEBUG: Register %s\n" ,
289- ce_algs [i ].alg .skcipher .base .cra_name );
290- err = crypto_register_skcipher (& ce_algs [i ].alg .skcipher );
293+ ce_algs [i ].alg .skcipher .base .base . cra_name );
294+ err = crypto_engine_register_skcipher (& ce_algs [i ].alg .skcipher );
291295 if (err ) {
292296 dev_err (ce -> dev , "Fail to register %s\n" ,
293- ce_algs [i ].alg .skcipher .base .cra_name );
297+ ce_algs [i ].alg .skcipher .base .base . cra_name );
294298 ce_algs [i ].ce = NULL ;
295299 return err ;
296300 }
@@ -313,8 +317,8 @@ static void sl3516_ce_unregister_algs(struct sl3516_ce_dev *ce)
313317 switch (ce_algs [i ].type ) {
314318 case CRYPTO_ALG_TYPE_SKCIPHER :
315319 dev_info (ce -> dev , "Unregister %d %s\n" , i ,
316- ce_algs [i ].alg .skcipher .base .cra_name );
317- crypto_unregister_skcipher (& ce_algs [i ].alg .skcipher );
320+ ce_algs [i ].alg .skcipher .base .base . cra_name );
321+ crypto_engine_unregister_skcipher (& ce_algs [i ].alg .skcipher );
318322 break ;
319323 }
320324 }
@@ -473,13 +477,20 @@ static int sl3516_ce_probe(struct platform_device *pdev)
473477
474478 pm_runtime_put_sync (ce -> dev );
475479
480+ if (IS_ENABLED (CONFIG_CRYPTO_DEV_SL3516_DEBUG )) {
481+ struct dentry * dbgfs_dir __maybe_unused ;
482+ struct dentry * dbgfs_stats __maybe_unused ;
483+
484+ /* Ignore error of debugfs */
485+ dbgfs_dir = debugfs_create_dir ("sl3516" , NULL );
486+ dbgfs_stats = debugfs_create_file ("stats" , 0444 ,
487+ dbgfs_dir , ce ,
488+ & sl3516_ce_debugfs_fops );
476489#ifdef CONFIG_CRYPTO_DEV_SL3516_DEBUG
477- /* Ignore error of debugfs */
478- ce -> dbgfs_dir = debugfs_create_dir ("sl3516" , NULL );
479- ce -> dbgfs_stats = debugfs_create_file ("stats" , 0444 ,
480- ce -> dbgfs_dir , ce ,
481- & sl3516_ce_debugfs_fops );
490+ ce -> dbgfs_dir = dbgfs_dir ;
491+ ce -> dbgfs_stats = dbgfs_stats ;
482492#endif
493+ }
483494
484495 return 0 ;
485496error_pmuse :
0 commit comments