From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Gerd Hoffmann" <kraxel@redhat.com>
Cc: Markus Schneider-Pargmann <msp@baylibre.com>,
Patrik Jakobsson <patrik.r.jakobsson@gmail.com>,
Jianmin Lv <lvjianmin@loongson.cn>,
Qianhai Wu <wuqianhai@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>,
Mingcong Bai <jeffbai@aosc.io>, Xi Ruoyao <xry111@xry111.site>,
Icenowy Zheng <zhengxingda@iscas.ac.cn>,
Dave Airlie <airlied@redhat.com>,
Jocelyn Falempe <jfalempe@redhat.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux.dev,
spice-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Consistently define pci_device_ids using named initializers
Date: Wed, 17 Jun 2026 11:11:32 +0200 [thread overview]
Message-ID: <bc89deb2-2a2e-41c5-8cd9-28b794020972@suse.de> (raw)
In-Reply-To: <b13678d8-1159-457a-bcab-ade06bea0cf8@suse.de>
Am 12.06.26 um 14:10 schrieb Thomas Zimmermann:
> Hi
>
> Am 04.05.26 um 17:05 schrieb Uwe Kleine-König (The Capable Hub):
>> 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>
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
>
> I'll merge the patch into drm-misc-next.
Merged with a minor change to coding style in gma500.
>
> Best regards
> Thomas
>
>> ---
>> 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
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
next prev parent reply other threads:[~2026-06-17 9:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 15:05 [PATCH] drm: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-06-10 16:57 ` Uwe Kleine-König (The Capable Hub)
2026-06-10 19:24 ` Patrik Jakobsson
2026-06-12 12:10 ` Thomas Zimmermann
2026-06-17 9:11 ` Thomas Zimmermann [this message]
2026-06-17 10:59 ` Uwe Kleine-König (The Capable Hub)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc89deb2-2a2e-41c5-8cd9-28b794020972@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=chenhuacai@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeffbai@aosc.io \
--cc=jfalempe@redhat.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvjianmin@loongson.cn \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=msp@baylibre.com \
--cc=patrik.r.jakobsson@gmail.com \
--cc=simona@ffwll.ch \
--cc=spice-devel@lists.freedesktop.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=virtualization@lists.linux.dev \
--cc=wuqianhai@loongson.cn \
--cc=xry111@xry111.site \
--cc=zhengxingda@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox