[PATCH] Move struct cpu_feature to a <linux/device-id/cpu_feature.h>
From: Nicolas Schier
Date: Fri Nov 20 2026 - 15:27:36 EST
From: Nicolas Schier <n.schier@xxxxxxxxx>
struct cpu_feature used to be defined in <linux/mod_devicetable.h>. Move
it to <linux/device-id/cpu_feature.h> to let users of mod_devicetable.h
that only need struct cpu_feature switch to the new include file, and
to reduce the number of users of mod_devicetable.h.
While moving struct cpu_feature to <linux/cpufeature.h> instead sounds
reasonable, it would break defconfig on loongarch and mips [1].
Link: https://lore.kernel.org/r/f610c07f39df15f3e7ebdc63bfcd759ca7a687a8.1794233316.git.sashal@xxxxxxxxxx # [1]
Original-patch-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
Original-patch-by: Sasha Levin <sashal@xxxxxxxxxx>
Signed-off-by: Nicolas Schier <n.schier@xxxxxxxxx>
---
This patch is a combination of [1] and [2]; both patches have been
merged to prevent failures during bisecting.
Acked-by, Reported-by and Closes tags have been dropped due to the
rewrite.
Thanks to Uwe and Sasha!
[2]: https://patch.msgid.link/bc9fbf5784f6788e10c749a05d56c42bdb68f3d9.1792144769.git.u.kleine-koenig@xxxxxxxxxxxx
---
arch/loongarch/kvm/main.c | 2 +-
include/linux/cpufeature.h | 3 ++-
include/linux/device-id/cpu_feature.h | 23 +++++++++++++++++++++++
include/linux/mod_devicetable.h | 14 +-------------
4 files changed, 27 insertions(+), 15 deletions(-)
create mode 100644 include/linux/device-id/cpu_feature.h
diff --git a/arch/loongarch/kvm/main.c b/arch/loongarch/kvm/main.c
index c65ae2fa4c4b..fb3dc8237499 100644
--- a/arch/loongarch/kvm/main.c
+++ b/arch/loongarch/kvm/main.c
@@ -5,7 +5,7 @@
#include <linux/err.h>
#include <linux/module.h>
-#include <linux/mod_devicetable.h>
+#include <linux/device-id/cpu_feature.h>
#include <linux/kvm_host.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
diff --git a/include/linux/cpufeature.h b/include/linux/cpufeature.h
index 6aff540ee9e5..cd470987777f 100644
--- a/include/linux/cpufeature.h
+++ b/include/linux/cpufeature.h
@@ -6,10 +6,11 @@
#ifndef __LINUX_CPUFEATURE_H
#define __LINUX_CPUFEATURE_H
+#include <linux/device-id/cpu_feature.h>
+
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
#include <linux/init.h>
-#include <linux/mod_devicetable.h>
#include <asm/cpufeature.h>
/*
diff --git a/include/linux/device-id/cpu_feature.h b/include/linux/device-id/cpu_feature.h
new file mode 100644
index 000000000000..e14fe8bba85a
--- /dev/null
+++ b/include/linux/device-id/cpu_feature.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef LINUX_DEVICE_ID_CPU_FEATURE_H
+#define LINUX_DEVICE_ID_CPU_FEATURE_H
+
+/*
+ * This file is included by scripts/mod/file2alias.c which is compiled
+ * using the host compiler which might not have <linux/types.h> but the
+ * __u{8,16,32} types are defined there locally.
+ */
+#ifdef __KERNEL__
+#include <linux/types.h>
+#endif
+
+/*
+ * Generic table type for matching CPU features.
+ * @feature: the bit number of the feature (0 - 65535)
+ */
+
+struct cpu_feature {
+ __u16 feature;
+};
+
+#endif /* ifndef LINUX_DEVICE_ID_CPU_FEATURE_H */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index d1581bb64729..a69947f2c1dc 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -8,10 +8,6 @@
#ifndef LINUX_MOD_DEVICETABLE_H
#define LINUX_MOD_DEVICETABLE_H
-#ifdef __KERNEL__
-#include <linux/types.h>
-#endif
-
#include "device-id/acpi.h"
#include "device-id/amba.h"
#include "device-id/ap.h"
@@ -21,6 +17,7 @@
#include "device-id/ccw.h"
#include "device-id/cdx.h"
#include "device-id/coreboot.h"
+#include "device-id/cpu_feature.h"
#include "device-id/css.h"
#include "device-id/dfl.h"
#include "device-id/dmi.h"
@@ -69,13 +66,4 @@
#include "device-id/x86_cpu.h"
#include "device-id/zorro.h"
-/*
- * Generic table type for matching CPU features.
- * @feature: the bit number of the feature (0 - 65535)
- */
-
-struct cpu_feature {
- __u16 feature;
-};
-
#endif /* LINUX_MOD_DEVICETABLE_H */
--
2.47.3