Re: [PATCH v3] serial: 8250_pci: Consistently define pci_device_ids using named initializers

From: Uwe Kleine-König (The Capable Hub)

Date: Wed Jun 03 2026 - 02:13:47 EST


On Tue, Jun 02, 2026 at 10:20:56PM +0200, Andy Shevchenko wrote:
> On Tue, Apr 28, 2026 at 04:40:33PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> > ... and PCI device helpers.
> >
> > The various struct pci_device_id were defined using a mixture of
> > initialization by position and by name. Some use the PCI device helpers
> > (like PCI_DEVICE and PCI_DEVICE_SUB) and others don't.
> >
> > Consistently use named initializers, drop assignments of 0 by position
> > for .class and .class_mask and use the PCI device helpers. Also use
> > consistent line-breaks and positioning for opening and closing curly
> > braces.
> >
> > 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@xxxxxxxxxxxx/)
> > and that requires named initializers. But it's also a nice cleanup on
> > its own.
> >
> > This patch doesn't change the compiled result; this was verified using
> > an allmodconfig with several things disabled that make reproducible
> > builds harder on x86 and arm64.
>
> This patch broke the build.
>
> drivers/tty/serial/8250/8250_pci.c:5398:12: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
> 5398 | .class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/pci_ids.h:74:45: note: expanded from macro 'PCI_CLASS_COMMUNICATION_MULTISERIAL'
> 74 | #define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702
>
> and so on...

Oh, it works fine for me with clang 19.1.7, gcc 11.3.0, gcc 12.4.0, gcc
13.3.0, gcc 14.2.0 and gcc 15.2.0, but I agree it's a bit obscure
because .class and .class_mask are specified twice; once by PCI_VDEVICE
and once explicitly.

Which compiler are you using that breaks here? I guess I might have
broken more drivers this way, so it would be great to have a setup to
reproduce your issue.

Once all the initializer are converted to named initialisation, we
should definitively drop the assignment to .class and .class_mask in
PCI_VDEVICE, but that doesn't work yet.

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature