crypto: arm64/ghash - Reduce boilerplate
Subsystems (2)
PATCH 1/1 crypto: arm64/ghash - Reduce boilerplate
Make use of module_cpu_feature_match() which expands to nearly the code that is typed out.
Signed-off-by Uwe Kleine-König <[email protected]>
--- arch/arm64/crypto/ghash-ce-glue.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/crypto/ghash-ce-glue.c +3 -7
@@ -384,7 +384,8 @@ static struct aead_alg gcm_aes_algs[] = {{static int __init ghash_ce_mod_init (void ) { -if (!cpu_have_named_feature (ASIMD ) || !cpu_have_named_feature (PMULL )) +/* ASIMD is implied by PMULL, but better be safe than sorry */ +if (!cpu_have_named_feature (ASIMD ))return -ENODEV ;return crypto_register_aeads (gcm_aes_algs,ARRAY_SIZE (gcm_aes_algs));
@@ -395,10 +396,5 @@ static void __exit ghash_ce_mod_exit(void)crypto_unregister_aeads (gcm_aes_algs,ARRAY_SIZE (gcm_aes_algs)); } -static const struct cpu_feature __maybe_unused ghash_cpu_feature[] = { - {cpu_feature (PMULL ) }, { } -}; -MODULE_DEVICE_TABLE (cpu, ghash_cpu_feature); - -module_init (ghash_ce_mod_init); +module_cpu_feature_match (PMULL , ghash_ce_mod_init);module_exit (ghash_ce_mod_exit);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.56.0.rc1
Quoted 13 lines · Uwe Kleine-König
Make use of
module_cpu_feature_match()which expands to nearly the code that is typed out.Signed-off-by Uwe Kleine-König <[email protected]>--- arch/arm64/crypto/ghash-ce-glue.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)arch/arm64/crypto/ghash-ce-glue.c +0
-0
arch/arm64/crypto/ghash-ce-glue.c static struct aead_alg gcm_aes_algs[] = {{ · line 389
Quoted 7 lines
arch/arm64/crypto/ghash-ce-glue.c +2
-1@@ -384,7 +384,8 @@ static struct aead_alg gcm_aes_algs[] = {{static int __init ghash_ce_mod_init (void ) { -if (!cpu_have_named_feature (ASIMD ) || !cpu_have_named_feature (PMULL )) +/* ASIMD is implied by PMULL, but better be safe than sorry */ +if (!cpu_have_named_feature (ASIMD ))return -ENODEV ;
The ASIMD check can be dropped too. There's already other code that assumes PMULL implies ASIMD.
- Eric