![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org> 0004 */ 0005 0006 #ifndef __LINUX_CPUFEATURE_H 0007 #define __LINUX_CPUFEATURE_H 0008 0009 #ifdef CONFIG_GENERIC_CPU_AUTOPROBE 0010 0011 #include <linux/init.h> 0012 #include <linux/mod_devicetable.h> 0013 #include <asm/cpufeature.h> 0014 0015 /* 0016 * Macros imported from <asm/cpufeature.h>: 0017 * - cpu_feature(x) ordinal value of feature called 'x' 0018 * - cpu_have_feature(u32 n) whether feature #n is available 0019 * - MAX_CPU_FEATURES upper bound for feature ordinal values 0020 * Optional: 0021 * - CPU_FEATURE_TYPEFMT format string fragment for printing the cpu type 0022 * - CPU_FEATURE_TYPEVAL set of values matching the format string above 0023 */ 0024 0025 #ifndef CPU_FEATURE_TYPEFMT 0026 #define CPU_FEATURE_TYPEFMT "%s" 0027 #endif 0028 0029 #ifndef CPU_FEATURE_TYPEVAL 0030 #define CPU_FEATURE_TYPEVAL ELF_PLATFORM 0031 #endif 0032 0033 /* 0034 * Use module_cpu_feature_match(feature, module_init_function) to 0035 * declare that 0036 * a) the module shall be probed upon discovery of CPU feature 'feature' 0037 * (typically at boot time using udev) 0038 * b) the module must not be loaded if CPU feature 'feature' is not present 0039 * (not even by manual insmod). 0040 * 0041 * For a list of legal values for 'feature', please consult the file 0042 * 'asm/cpufeature.h' of your favorite architecture. 0043 */ 0044 #define module_cpu_feature_match(x, __initfunc) \ 0045 static struct cpu_feature const __maybe_unused cpu_feature_match_ ## x[] = \ 0046 { { .feature = cpu_feature(x) }, { } }; \ 0047 MODULE_DEVICE_TABLE(cpu, cpu_feature_match_ ## x); \ 0048 \ 0049 static int __init cpu_feature_match_ ## x ## _init(void) \ 0050 { \ 0051 if (!cpu_have_feature(cpu_feature(x))) \ 0052 return -ENODEV; \ 0053 return __initfunc(); \ 0054 } \ 0055 module_init(cpu_feature_match_ ## x ## _init) 0056 0057 #endif 0058 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |