These macros are often used by drivers and we have already a lot of
duplication as ICPU() macro across the drivers.

Provide a generic x86 macro for users.

Note, as Ingo Molnar pointed out this has a hidden issue when a driver
needs to preserve const qualifier. Though, it would be addressed
separately at some point.

[1]: https://lkml.org/lkml/2017/12/28/85

Signed-off-by: Andy Shevchenko <[email protected]>
---
 arch/x86/include/asm/intel-family.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/x86/include/asm/intel-family.h 
b/arch/x86/include/asm/intel-family.h
index cf090e584202..7ed08a7c3398 100644
--- a/arch/x86/include/asm/intel-family.h
+++ b/arch/x86/include/asm/intel-family.h
@@ -76,4 +76,17 @@
 #define INTEL_FAM6_XEON_PHI_KNL                0x57 /* Knights Landing */
 #define INTEL_FAM6_XEON_PHI_KNM                0x85 /* Knights Mill */
 
+/* Useful macros */
+#define INTEL_CPU_FAM_ANY(_family, _model, _driver_data)       \
+{                                                              \
+       .vendor         = X86_VENDOR_INTEL,                     \
+       .family         = _family,                              \
+       .model          = _model,                               \
+       .feature        = X86_FEATURE_ANY,                      \
+       .driver_data    = (kernel_ulong_t)&_driver_data         \
+}
+
+#define INTEL_CPU_FAM6(_model, _driver_data)                   \
+       INTEL_CPU_FAM_ANY(6, INTEL_FAM6_##_model, _driver_data)
+
 #endif /* _ASM_X86_INTEL_FAMILY_H */
-- 
2.18.0

Reply via email to