hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/crypto/vmx/vmx.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * Routines supporting VMX instructions on the Power 8
34 *
45 * Copyright (C) 2015 International Business Machines Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; version 2 only.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
186 *
197 * Author: Marcelo Henrique Cerri <mhcerri@br.ibm.com>
208 */
....@@ -27,54 +15,58 @@
2715 #include <linux/crypto.h>
2816 #include <asm/cputable.h>
2917 #include <crypto/internal/hash.h>
18
+#include <crypto/internal/skcipher.h>
3019
3120 extern struct shash_alg p8_ghash_alg;
3221 extern struct crypto_alg p8_aes_alg;
33
-extern struct crypto_alg p8_aes_cbc_alg;
34
-extern struct crypto_alg p8_aes_ctr_alg;
35
-extern struct crypto_alg p8_aes_xts_alg;
36
-static struct crypto_alg *algs[] = {
37
- &p8_aes_alg,
38
- &p8_aes_cbc_alg,
39
- &p8_aes_ctr_alg,
40
- &p8_aes_xts_alg,
41
- NULL,
42
-};
22
+extern struct skcipher_alg p8_aes_cbc_alg;
23
+extern struct skcipher_alg p8_aes_ctr_alg;
24
+extern struct skcipher_alg p8_aes_xts_alg;
4325
44
-int __init p8_init(void)
26
+static int __init p8_init(void)
4527 {
46
- int ret = 0;
47
- struct crypto_alg **alg_it;
48
-
49
- for (alg_it = algs; *alg_it; alg_it++) {
50
- ret = crypto_register_alg(*alg_it);
51
- printk(KERN_INFO "crypto_register_alg '%s' = %d\n",
52
- (*alg_it)->cra_name, ret);
53
- if (ret) {
54
- for (alg_it--; alg_it >= algs; alg_it--)
55
- crypto_unregister_alg(*alg_it);
56
- break;
57
- }
58
- }
59
- if (ret)
60
- return ret;
28
+ int ret;
6129
6230 ret = crypto_register_shash(&p8_ghash_alg);
63
- if (ret) {
64
- for (alg_it = algs; *alg_it; alg_it++)
65
- crypto_unregister_alg(*alg_it);
66
- }
31
+ if (ret)
32
+ goto err;
33
+
34
+ ret = crypto_register_alg(&p8_aes_alg);
35
+ if (ret)
36
+ goto err_unregister_ghash;
37
+
38
+ ret = crypto_register_skcipher(&p8_aes_cbc_alg);
39
+ if (ret)
40
+ goto err_unregister_aes;
41
+
42
+ ret = crypto_register_skcipher(&p8_aes_ctr_alg);
43
+ if (ret)
44
+ goto err_unregister_aes_cbc;
45
+
46
+ ret = crypto_register_skcipher(&p8_aes_xts_alg);
47
+ if (ret)
48
+ goto err_unregister_aes_ctr;
49
+
50
+ return 0;
51
+
52
+err_unregister_aes_ctr:
53
+ crypto_unregister_skcipher(&p8_aes_ctr_alg);
54
+err_unregister_aes_cbc:
55
+ crypto_unregister_skcipher(&p8_aes_cbc_alg);
56
+err_unregister_aes:
57
+ crypto_unregister_alg(&p8_aes_alg);
58
+err_unregister_ghash:
59
+ crypto_unregister_shash(&p8_ghash_alg);
60
+err:
6761 return ret;
6862 }
6963
70
-void __exit p8_exit(void)
64
+static void __exit p8_exit(void)
7165 {
72
- struct crypto_alg **alg_it;
73
-
74
- for (alg_it = algs; *alg_it; alg_it++) {
75
- printk(KERN_INFO "Removing '%s'\n", (*alg_it)->cra_name);
76
- crypto_unregister_alg(*alg_it);
77
- }
66
+ crypto_unregister_skcipher(&p8_aes_xts_alg);
67
+ crypto_unregister_skcipher(&p8_aes_ctr_alg);
68
+ crypto_unregister_skcipher(&p8_aes_cbc_alg);
69
+ crypto_unregister_alg(&p8_aes_alg);
7870 crypto_unregister_shash(&p8_ghash_alg);
7971 }
8072
....@@ -86,3 +78,4 @@
8678 "support on Power 8");
8779 MODULE_LICENSE("GPL");
8880 MODULE_VERSION("1.0.0");
81
+MODULE_IMPORT_NS(CRYPTO_INTERNAL);