.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Accelerated CRC32(C) using ARM CRC, NEON and Crypto Extensions instructions |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org> |
---|
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 version 2 as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/cpufeature.h> |
---|
.. | .. |
---|
16 | 13 | #include <linux/string.h> |
---|
17 | 14 | |
---|
18 | 15 | #include <crypto/internal/hash.h> |
---|
| 16 | +#include <crypto/internal/simd.h> |
---|
19 | 17 | |
---|
20 | 18 | #include <asm/hwcap.h> |
---|
21 | 19 | #include <asm/neon.h> |
---|
.. | .. |
---|
56 | 54 | { |
---|
57 | 55 | u32 *mctx = crypto_shash_ctx(hash); |
---|
58 | 56 | |
---|
59 | | - if (keylen != sizeof(u32)) { |
---|
60 | | - crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
| 57 | + if (keylen != sizeof(u32)) |
---|
61 | 58 | return -EINVAL; |
---|
62 | | - } |
---|
63 | 59 | *mctx = le32_to_cpup((__le32 *)key); |
---|
64 | 60 | return 0; |
---|
65 | 61 | } |
---|
.. | .. |
---|
113 | 109 | u32 *crc = shash_desc_ctx(desc); |
---|
114 | 110 | unsigned int l; |
---|
115 | 111 | |
---|
116 | | - if (may_use_simd()) { |
---|
| 112 | + if (crypto_simd_usable()) { |
---|
117 | 113 | if ((u32)data % SCALE_F) { |
---|
118 | 114 | l = min_t(u32, length, SCALE_F - ((u32)data % SCALE_F)); |
---|
119 | 115 | |
---|
.. | .. |
---|
147 | 143 | u32 *crc = shash_desc_ctx(desc); |
---|
148 | 144 | unsigned int l; |
---|
149 | 145 | |
---|
150 | | - if (may_use_simd()) { |
---|
| 146 | + if (crypto_simd_usable()) { |
---|
151 | 147 | if ((u32)data % SCALE_F) { |
---|
152 | 148 | l = min_t(u32, length, SCALE_F - ((u32)data % SCALE_F)); |
---|
153 | 149 | |
---|