From: Niklas Cassel <cassel@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: "Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Mikael Pettersson" <mikpelinux@gmail.com>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] ata: Use named initializers for pci_device_id arrays
Date: Fri, 12 Jun 2026 20:03:33 +0200 [thread overview]
Message-ID: <aixJ9VAzpOSNKxNm@ryzen> (raw)
In-Reply-To: <20260612162904.396dbc1f@pumpkin>
Hello David,
On Fri, Jun 12, 2026 at 04:29:04PM +0100, David Laight wrote:
> On Fri, 12 Jun 2026 10:21:48 +0200
> Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> wrote:
>
> > While being less compact, using named initializers allows to more easily
> > see which members of the structs are assigned which value without having
> > to lookup the declaration of the struct. And it's also more robust
> > against changes to the struct definition.
>
> I think I'd try to keep each entry on one line for readability.
> Either by just letting the line be long or using a #define for the initialiser.
>
> ...
> > diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c
> > index 3999305b5356..402d3304b94b 100644
> > --- a/drivers/ata/acard-ahci.c
> > +++ b/drivers/ata/acard-ahci.c
> > @@ -91,9 +91,11 @@ static const struct ata_port_info acard_ahci_port_info[] = {
> > };
> >
> > static const struct pci_device_id acard_ahci_pci_tbl[] = {
> > - /* ACard */
> > - { PCI_VDEVICE(ARTOP, 0x000d), board_acard_ahci }, /* ATP8620 */
> > -
> > + {
> > + /* ACard ATP8620 */
> > + PCI_VDEVICE(ARTOP, 0x000d),
> > + .driver_data = board_acard_ahci,
> > + },
> > { } /* terminate list */
> > };
>
>
> Why not extend PCI_VDEVICE so you can pass it the .driver data
> (and other named initializers), something like:
>
> #define PCI_VDEVICE(vend, dev, ...) \
> .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
> .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0 \
> __VA_OPT__(, .driver_data = __VA_ARGS__)
>
> The change to all the files is then just to move the )
> (and the old versions will still compile).
> You can also do:
> PCI_VDEVICE(XXX, 0xx, board_xxx, .override_only = 1)
>
> At which point you can move the {} inside - but that is a breaking change.
>
> Note that sparse won't grok __VA_OPT__() so will need an alternate definition.
Sounds like a good idea to me, but it also sounds like it would touch
include/linux/pci.h, so probably would need to go via the PCI tree.
But if you manage to get your suggested macro included, I would be happy
to take patches that makes use of it. (Or even carry to carry a patch that
adds the macro if you manage to get an Acked-by from the PCI maintainers.)
Kind regards,
Niklas
next prev parent reply other threads:[~2026-06-12 18:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 8:21 [PATCH v3 0/2] ata: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-06-12 8:21 ` [PATCH v3 1/2] ata: Drop unused assignments of pci_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-06-12 8:21 ` [PATCH v3 2/2] ata: Use named initializers for pci_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-06-12 11:53 ` Damien Le Moal
2026-06-12 15:29 ` David Laight
2026-06-12 18:03 ` Niklas Cassel [this message]
2026-06-12 11:01 ` [PATCH v3 0/2] ata: Consistently define pci_device_ids using named initializers Niklas Cassel
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=aixJ9VAzpOSNKxNm@ryzen \
--to=cassel@kernel.org \
--cc=david.laight.linux@gmail.com \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikpelinux@gmail.com \
--cc=u.kleine-koenig@baylibre.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.