]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: arm/sha1-ce - enable module autoloading based on CPU feature bits
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sun, 21 May 2017 10:23:38 +0000 (10:23 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 1 Jun 2017 04:55:40 +0000 (12:55 +0800)
Make the module autoloadable by tying it to the CPU feature bit that
describes whether the optional instructions it relies on are implemented
by the current CPU.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm/crypto/sha1-ce-glue.c

index 80bc2fcd241a3659f31ea48b26fededbacb41cea..555f72b5e659bb5d6cff2de9e9215b551f8680d7 100644 (file)
@@ -11,6 +11,7 @@
 #include <crypto/internal/hash.h>
 #include <crypto/sha.h>
 #include <crypto/sha1_base.h>
+#include <linux/cpufeature.h>
 #include <linux/crypto.h>
 #include <linux/module.h>
 
@@ -82,8 +83,6 @@ static struct shash_alg alg = {
 
 static int __init sha1_ce_mod_init(void)
 {
-       if (!(elf_hwcap2 & HWCAP2_SHA1))
-               return -ENODEV;
        return crypto_register_shash(&alg);
 }
 
@@ -92,5 +91,5 @@ static void __exit sha1_ce_mod_fini(void)
        crypto_unregister_shash(&alg);
 }
 
-module_init(sha1_ce_mod_init);
+module_cpu_feature_match(SHA1, sha1_ce_mod_init);
 module_exit(sha1_ce_mod_fini);