forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/arch/x86/crypto/cast5_avx_glue.c
....@@ -1,24 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
2
- * Glue Code for the AVX assembler implemention of the Cast5 Cipher
3
+ * Glue Code for the AVX assembler implementation of the Cast5 Cipher
34 *
45 * Copyright (C) 2012 Johannes Goetzfried
56 * <Johannes.Goetzfried@informatik.stud.uni-erlangen.de>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
- * USA
21
- *
227 */
238
249 #include <asm/crypto/glue_helper.h>
....@@ -61,7 +46,7 @@
6146
6247 static int ecb_crypt(struct skcipher_request *req, bool enc)
6348 {
64
- bool fpu_enabled = false;
49
+ bool fpu_enabled;
6550 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
6651 struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm);
6752 struct skcipher_walk walk;
....@@ -76,7 +61,7 @@
7661 u8 *wsrc = walk.src.virt.addr;
7762 u8 *wdst = walk.dst.virt.addr;
7863
79
- fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes);
64
+ fpu_enabled = cast5_fpu_begin(false, &walk, nbytes);
8065
8166 /* Process multi-block batch */
8267 if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
....@@ -105,10 +90,9 @@
10590 } while (nbytes >= bsize);
10691
10792 done:
93
+ cast5_fpu_end(fpu_enabled);
10894 err = skcipher_walk_done(&walk, nbytes);
10995 }
110
-
111
- cast5_fpu_end(fpu_enabled);
11296 return err;
11397 }
11498
....@@ -212,7 +196,7 @@
212196 {
213197 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
214198 struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm);
215
- bool fpu_enabled = false;
199
+ bool fpu_enabled;
216200 struct skcipher_walk walk;
217201 unsigned int nbytes;
218202 int err;
....@@ -220,12 +204,11 @@
220204 err = skcipher_walk_virt(&walk, req, false);
221205
222206 while ((nbytes = walk.nbytes)) {
223
- fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes);
207
+ fpu_enabled = cast5_fpu_begin(false, &walk, nbytes);
224208 nbytes = __cbc_decrypt(ctx, &walk);
209
+ cast5_fpu_end(fpu_enabled);
225210 err = skcipher_walk_done(&walk, nbytes);
226211 }
227
-
228
- cast5_fpu_end(fpu_enabled);
229212 return err;
230213 }
231214
....@@ -292,7 +275,7 @@
292275 {
293276 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
294277 struct cast5_ctx *ctx = crypto_skcipher_ctx(tfm);
295
- bool fpu_enabled = false;
278
+ bool fpu_enabled;
296279 struct skcipher_walk walk;
297280 unsigned int nbytes;
298281 int err;
....@@ -300,12 +283,11 @@
300283 err = skcipher_walk_virt(&walk, req, false);
301284
302285 while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) {
303
- fpu_enabled = cast5_fpu_begin(fpu_enabled, &walk, nbytes);
286
+ fpu_enabled = cast5_fpu_begin(false, &walk, nbytes);
304287 nbytes = __ctr_crypt(&walk, ctx);
288
+ cast5_fpu_end(fpu_enabled);
305289 err = skcipher_walk_done(&walk, nbytes);
306290 }
307
-
308
- cast5_fpu_end(fpu_enabled);
309291
310292 if (walk.nbytes) {
311293 ctr_crypt_final(&walk, ctx);