On Mon, May 4, 2026 at 5:05 PM Uwe Kleine-König (The Capable Hub) <[email protected]> wrote: > > 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) > <[email protected]>
Reviewed-by: Patrik Jakobsson <[email protected]> Since it touches multiple drivers, perhaps a drm-misc maintainer can take this? -Patrik > --- > Hello, > > The secret plan is to make struct pci_device_id::driver_data an > anonymous union (similar to > https://lore.kernel.org/all/[email protected]/) > 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 >

