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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use designated initializers for struct pci_device_id in kernel 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@xxxxxxxxx
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 include/drm/i915_pciids.h | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
index 0987bc12476f..7baf14fcb7c2 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,					\
 		(unsigned long)(__info),				\
 	}
+#endif
 
 #define INTEL_VGA_DEVICE(__id, __info)			\
 	INTEL_VGA_DEVICE_INIT(__id, ~0, ~0, __info)
-- 
2.34.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux