diff mbox series

[2/3] drm/i915/pciids: use designated initializers for struct pci_device_id

Message ID 20220311101854.146911-2-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/i915/pciids: add common INTEL_VGA_DEVICE_INIT macro | expand

Commit Message

Jani Nikula March 11, 2022, 10:18 a.m. UTC
Use designated initializers for struct pci_device_id to avoid the
dependency on struct pci_device_id remaining unchanged. Recently, commit
343b7258687e ("PCI: Add 'override_only' field to struct pci_device_id")
added a new member leading to warnings about missing field initializers.

Any userspace using this header should switch to defining their own
initializers. The old one is left in place for now.

References: https://lore.kernel.org/all/202108272322.EipbBEAp-lkp@intel.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 include/drm/i915_pciids.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
index 637333c9e1c0..2831614f8725 100644
--- a/include/drm/i915_pciids.h
+++ b/include/drm/i915_pciids.h
@@ -25,15 +25,18 @@ 
 #ifndef _I915_PCIIDS_H
 #define _I915_PCIIDS_H
 
+#ifdef __KERNEL__
+/* Initializer for struct pci_device_id */
+#define INTEL_VGA_DEVICE_INIT(__id, __subvendor, __subdevice, __info) { \
+		.vendor = 0x8086, .device = (__id),			\
+		.subvendor = (__subvendor), .subdevice = (__subdevice),	\
+		.class = 0x030000, .class_mask = 0xff0000,		\
+		.driver_data = (kernel_ulong_t)(__info),		\
+	}
+#else
 /*
- * A pci_device_id struct {
- *	__u32 vendor, device;
- *      __u32 subvendor, subdevice;
- *	__u32 class, class_mask;
- *	kernel_ulong_t driver_data;
- * };
- * Don't use C99 here because "class" is reserved and we want to
- * give userspace flexibility.
+ * Transitional, non-kernel users should define INTEL_VGA_DEVICE_INIT()
+ * themselves.
  */
 #define INTEL_VGA_DEVICE_INIT(__id, __subvendor, __subdevice, __info) { \
 		0x8086, (__id),						\
@@ -41,6 +44,7 @@ 
 		0x030000, 0xff0000,					\
 		(kernel_ulong_t)(__info),				\
 	}
+#endif
 
 #define INTEL_VGA_DEVICE(__id, __info)			\
 	INTEL_VGA_DEVICE_INIT(__id, ~0, ~0, __info)