crypto: arm/crc32 - enable module autoloading based on CPU feature bits
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sun, 21 May 2017 10:23:40 +0000 (10:23 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 1 Jun 2017 04:55:42 +0000 (12:55 +0800)
Make the module autoloadable by tying it to the CPU feature bits that
describe 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/crc32-ce-glue.c

index e1566bec1016ee87204fe263c4d11fe3a6fc45e4..1b0e0e86ee9c205b16d306f8a76ee9cac90cfee2 100644 (file)
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/cpufeature.h>
 #include <linux/crc32.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -233,6 +234,11 @@ static void __exit crc32_pmull_mod_exit(void)
                                  ARRAY_SIZE(crc32_pmull_algs));
 }
 
+static const struct cpu_feature crc32_cpu_feature[] = {
+       { cpu_feature(CRC32) }, { cpu_feature(PMULL) }, { }
+};
+MODULE_DEVICE_TABLE(cpu, crc32_cpu_feature);
+
 module_init(crc32_pmull_mod_init);
 module_exit(crc32_pmull_mod_exit);