* [PATCH] drm: Consistently define pci_device_ids using named initializers
@ 2026-05-04 15:05 Uwe Kleine-König (The Capable Hub)
2026-05-04 22:10 ` Claude review: " Claude Code Review Bot
2026-05-04 22:10 ` Claude Code Review Bot
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-04 15:05 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Gerd Hoffmann
Cc: Markus Schneider-Pargmann, Patrik Jakobsson, Jianmin Lv,
Qianhai Wu, Huacai Chen, Mingcong Bai, Xi Ruoyao, Icenowy Zheng,
Dave Airlie, Jocelyn Falempe, dri-devel, linux-kernel,
virtualization, spice-devel
The .driver_data member of the various struct pci_device_id arrays were
initialized by list expressions. This isn't easily readable if you're
not into PCI. Using the PCI_DEVICE macro and named initializers is more
explicit and thus easier to parse. Also skip explicit assignments of 0
(which the compiler then takes care of).
This change doesn't introduce changes to the compiled pci_device_id
arrays. Tested on x86 and arm64.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Hello,
The secret plan is to make struct pci_device_id::driver_data an
anonymous union (similar to
https://lore.kernel.org/all/cover.1776579304.git.u.kleine-koenig@baylibre.com/)
and that requires named initializers. But IMHO it's also a nice cleanup
on its own.
The anonymous union will allow changes like the following:
- { PCI_DEVICE(0x8086, 0x8108), .driver_data = (long) &psb_chip_ops },
+ { PCI_DEVICE(0x8086, 0x8108), .driver_data_ptr = &psb_chip_ops },
(together with the respective change in the code when the value is
used). This gets rid of a bunch of casts and thus slightly improves
type safety.
Best regards
Uwe
drivers/gpu/drm/gma500/psb_drv.c | 56 +++++++++++++--------------
drivers/gpu/drm/loongson/lsdc_drv.c | 4 +-
drivers/gpu/drm/mgag200/mgag200_drv.c | 24 ++++++------
drivers/gpu/drm/qxl/qxl_drv.c | 15 ++++---
4 files changed, 52 insertions(+), 47 deletions(-)
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 005ab7f5355f..039da26ef24d 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -56,36 +56,36 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
*/
static const struct pci_device_id pciidlist[] = {
/* Poulsbo */
- { 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
- { 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
+ { PCI_DEVICE(0x8086, 0x8108), .driver_data = (long) &psb_chip_ops },
+ { PCI_DEVICE(0x8086, 0x8109), .driver_data = (long) &psb_chip_ops },
/* Oak Trail */
- { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
- { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4100), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4101), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4102), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4103), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4104), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4105), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4106), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4107), .driver_data = (long) &oaktrail_chip_ops },
+ { PCI_DEVICE(0x8086, 0x4108), .driver_data = (long) &oaktrail_chip_ops },
/* Cedar Trail */
- { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0be9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0bea, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0beb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0bec, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0bed, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0bee, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0x8086, 0x0bef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops },
- { 0, }
+ { PCI_DEVICE(0x8086, 0x0be0), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be1), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be2), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be3), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be4), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be5), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be6), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be7), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be8), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0be9), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0bea), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0beb), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0bec), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0bed), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0bee), .driver_data = (long) &cdv_chip_ops },
+ { PCI_DEVICE(0x8086, 0x0bef), .driver_data = (long) &cdv_chip_ops },
+ { }
};
MODULE_DEVICE_TABLE(pci, pciidlist);
diff --git a/drivers/gpu/drm/loongson/lsdc_drv.c b/drivers/gpu/drm/loongson/lsdc_drv.c
index 1ece1ea42f78..f9f7271ddbff 100644
--- a/drivers/gpu/drm/loongson/lsdc_drv.c
+++ b/drivers/gpu/drm/loongson/lsdc_drv.c
@@ -444,8 +444,8 @@ static const struct dev_pm_ops lsdc_pm_ops = {
};
static const struct pci_device_id lsdc_pciid_list[] = {
- {PCI_VDEVICE(LOONGSON, 0x7a06), CHIP_LS7A1000},
- {PCI_VDEVICE(LOONGSON, 0x7a36), CHIP_LS7A2000},
+ { PCI_VDEVICE(LOONGSON, 0x7a06), .driver_data = CHIP_LS7A1000 },
+ { PCI_VDEVICE(LOONGSON, 0x7a36), .driver_data = CHIP_LS7A2000 },
{ }
};
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index a32be27c39e8..8ad4ddb60ee6 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -205,18 +205,18 @@ int mgag200_device_init(struct mga_device *mdev,
*/
static const struct pci_device_id mgag200_pciidlist[] = {
- { PCI_VENDOR_ID_MATROX, 0x520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_PCI },
- { PCI_VENDOR_ID_MATROX, 0x521, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_AGP },
- { PCI_VENDOR_ID_MATROX, 0x522, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_A },
- { PCI_VENDOR_ID_MATROX, 0x524, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_SE_B },
- { PCI_VENDOR_ID_MATROX, 0x530, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EV },
- { PCI_VENDOR_ID_MATROX, 0x532, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_WB },
- { PCI_VENDOR_ID_MATROX, 0x533, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH },
- { PCI_VENDOR_ID_MATROX, 0x534, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_ER },
- { PCI_VENDOR_ID_MATROX, 0x536, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EW3 },
- { PCI_VENDOR_ID_MATROX, 0x538, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH3 },
- { PCI_VENDOR_ID_MATROX, 0x53a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_EH5 },
- {0,}
+ { PCI_VDEVICE(MATROX, 0x0520), .driver_data = G200_PCI },
+ { PCI_VDEVICE(MATROX, 0x0521), .driver_data = G200_AGP },
+ { PCI_VDEVICE(MATROX, 0x0522), .driver_data = G200_SE_A },
+ { PCI_VDEVICE(MATROX, 0x0524), .driver_data = G200_SE_B },
+ { PCI_VDEVICE(MATROX, 0x0530), .driver_data = G200_EV },
+ { PCI_VDEVICE(MATROX, 0x0532), .driver_data = G200_WB },
+ { PCI_VDEVICE(MATROX, 0x0533), .driver_data = G200_EH },
+ { PCI_VDEVICE(MATROX, 0x0534), .driver_data = G200_ER },
+ { PCI_VDEVICE(MATROX, 0x0536), .driver_data = G200_EW3 },
+ { PCI_VDEVICE(MATROX, 0x0538), .driver_data = G200_EH3 },
+ { PCI_VDEVICE(MATROX, 0x053a), .driver_data = G200_EH5 },
+ { }
};
MODULE_DEVICE_TABLE(pci, mgag200_pciidlist);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 2bbb1168a3ff..6c3c309b8e4d 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -50,11 +50,16 @@
#include "qxl_object.h"
static const struct pci_device_id pciidlist[] = {
- { 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8,
- 0xffff00, 0 },
- { 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_OTHER << 8,
- 0xffff00, 0 },
- { 0, 0, 0 },
+ {
+ PCI_DEVICE(0x1b36, 0x0100),
+ .class = PCI_CLASS_DISPLAY_VGA << 8,
+ .class_mask = 0xffff00
+ }, {
+ PCI_DEVICE(0x1b36, 0x0100),
+ .class = PCI_CLASS_DISPLAY_OTHER << 8,
+ .class_mask = 0xffff00
+ },
+ { },
};
MODULE_DEVICE_TABLE(pci, pciidlist);
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Claude review: drm: Consistently define pci_device_ids using named initializers
2026-05-04 15:05 [PATCH] drm: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
@ 2026-05-04 22:10 ` Claude Code Review Bot
2026-05-04 22:10 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-04 22:10 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**gma500/psb_drv.c** -- Correct conversion. The old positional form:
```c
{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops }
```
becomes:
```c
{ PCI_DEVICE(0x8086, 0x8108), .driver_data = (long) &psb_chip_ops }
```
`PCI_DEVICE` sets `.vendor`, `.device`, `.subvendor = PCI_ANY_ID`, `.subdevice = PCI_ANY_ID`, matching the original. The class/class_mask fields default to 0 just as before. The sentinel `{ 0, }` becoming `{ }` is also a nice cleanup. All 27 entries check out.
**loongson/lsdc_drv.c** -- Correct conversion. The old form already used `PCI_VDEVICE` but had positional `driver_data`:
```c
{PCI_VDEVICE(LOONGSON, 0x7a06), CHIP_LS7A1000}
```
The positional trailing value after `PCI_VDEVICE`'s `, 0, 0` expansion maps to `driver_data`, so switching to `.driver_data = CHIP_LS7A1000` is equivalent and more explicit. Also adds consistent whitespace inside the braces.
**mgag200/mgag200_drv.c** -- Correct conversion. The old form used `PCI_VENDOR_ID_MATROX` directly:
```c
{ PCI_VENDOR_ID_MATROX, 0x520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, G200_PCI }
```
becomes:
```c
{ PCI_VDEVICE(MATROX, 0x0520), .driver_data = G200_PCI }
```
`PCI_VDEVICE(MATROX, ...)` expands to `.vendor = PCI_VENDOR_ID_MATROX`, so the vendor is identical. The trailing `, 0, 0` in `PCI_VDEVICE` covers class/class_mask, matching the original. The leading-zero normalization (0x520 -> 0x0520) is a nice touch for consistent 4-digit PCI device IDs. Sentinel also cleaned up from `{0,}` to `{ }`.
**qxl/qxl_drv.c** -- Correct conversion. This is the most interesting case because the original entries used class matching:
```c
{ 0x1b36, 0x100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 0xffff00, 0 }
```
becomes:
```c
{ PCI_DEVICE(0x1b36, 0x0100), .class = PCI_CLASS_DISPLAY_VGA << 8, .class_mask = 0xffff00 }
```
`PCI_DEVICE` handles vendor/device/subvendor/subdevice, then `.class` and `.class_mask` are named explicitly, and `driver_data` defaults to 0 matching the original. This is the clearest win for readability -- the class-matching semantics are now obvious. The sentinel `{ 0, 0, 0 }` to `{ }` is also good.
**Minor nit:** In the qxl section, the brace style `}, {` on a single line (line 297 of the mbox) differs from the other drivers where each entry is on its own line. This is fine and arguably compact, but `}, \n\t{` might be slightly more consistent with the rest of the patch. Not a blocker.
**No functional issues found.** The conversions are all equivalent to the originals, the commit message accurately describes the change, and the motivation (preparing for the anonymous union in `driver_data`) is sound.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread* Claude review: drm: Consistently define pci_device_ids using named initializers
2026-05-04 15:05 [PATCH] drm: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-05-04 22:10 ` Claude review: " Claude Code Review Bot
@ 2026-05-04 22:10 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-05-04 22:10 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm: Consistently define pci_device_ids using named initializers
Author: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?=
<u.kleine-koenig@baylibre.com>
Patches: 1
Reviewed: 2026-05-05T08:10:52.264043
---
This is a single-patch cleanup that converts four DRM drivers' `pci_device_id` tables from positional initializers to named initializers using the `PCI_DEVICE` / `PCI_VDEVICE` macros and `.driver_data =` syntax. The change is purely mechanical and well-motivated: it improves readability and prepares for a future change to make `driver_data` an anonymous union (which requires named initializers).
The author states binary equivalence was verified on x86 and arm64, which is the right level of testing for this kind of change.
**Recommendation: This patch looks correct and ready to merge.** One minor nit below on the qxl conversion.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-04 22:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 15:05 [PATCH] drm: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-05-04 22:10 ` Claude review: " Claude Code Review Bot
2026-05-04 22:10 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox