From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>,
Krzysztof Halasa <khc@pm.waw.pl>,
Johannes Berg <johannes@sipsolutions.net>,
Markus Schneider-Pargmann <msp@baylibre.com>,
Steffen Klassert <klassert@kernel.org>,
David Dillow <dave@thedillows.org>,
Ion Badulescu <ionut@badula.org>,
Mark Einon <mark.einon@gmail.com>,
Rasesh Mody <rmody@marvell.com>,
GR-Linux-NIC-Dev@marvell.com,
Sudarsana Kalluru <skalluru@marvell.com>,
Manish Chopra <manishc@marvell.com>,
Potnuri Bharat Teja <bharat@chelsio.com>,
Denis Kirjanov <kirjanov@gmail.com>,
Jijie Shao <shaojijie@huawei.com>,
Jian Shen <shenjian15@huawei.com>,
Cai Huoqing <cai.huoqing@linux.dev>,
Fan Gong <gongfan1@huawei.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Tariq Toukan <tariqt@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>,
Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>,
Yibo Dong <dong100@mucse.com>, Simon Horman <horms@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
nic_swsd@realtek.com, Jiri Pirko <jiri@resnulli.us>,
Francois Romieu <romieu@fr.zoreil.com>,
Daniele Venzano <venza@brownhat.org>,
Samuel Chessman <chessman@tux.org>,
Jiawen Wu <jiawenwu@trustnetic.com>,
Mengyuan Lou <mengyuanlou@net-swift.com>,
Kevin Curtis <kevin.curtis@farsite.co.uk>,
Arend van Spriel <arend.vanspriel@broadcom.com>,
Stanislav Yakovlev <stas.yakovlev@gmail.com>,
Richard Cochran <richardcochran@gmail.com>,
Kees Cook <kees@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
Thomas Fourier <fourier.thomas@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Kory Maincent <kory.maincent@bootlin.com>,
Zilin Guan <zilin@seu.edu.cn>,
Marco Crivellari <marco.crivellari@suse.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Jacob Keller <jacob.e.keller@intel.com>,
Philipp Stanner <phasta@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Yeounsu Moon <yyyynoom@gmail.com>,
Denis Benato <benato.denis96@gmail.com>,
Peiyang Wang <wangpeiyang1@huawei.com>,
Yonglong Liu <liuyonglong@huawei.com>,
Yicong Hui <yiconghui@gmail.com>,
Randy Dunlap <rdunlap@infradead.org>,
MD Danish Anwar <danishanwar@ti.com>,
Nathan Chancellor <nathan@kernel.org>,
Sai Krishna <saikrishnag@marvell.com>,
Ethan Nelson-Moore <enelsonmoore@gmail.com>,
Larysa Zaremba <larysa.zaremba@intel.com>,
Joe Damato <joe@dama.to>, Double Lo <double.lo@cypress.com>,
Chi-hsien Lin <chi-hsien.lin@cypress.com>,
Colin Ian King <colin.i.king@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-can@vger.kernel.org, linux-parisc@vger.kernel.org,
intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org,
oss-drivers@corigine.com, linux-wireless@vger.kernel.org,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com
Subject: Re: [PATCH net-next] net: Consistently define pci_device_ids using named initializers
Date: Wed, 29 Apr 2026 09:54:54 +0300 [thread overview]
Message-ID: <afGrPvUeZ-DjWbC8@ashevche-desk.local> (raw)
In-Reply-To: <20260428171845.2288395-2-u.kleine-koenig@baylibre.com>
On Tue, Apr 28, 2026 at 07:18:44PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> ... and PCI device helpers.
>
> The various struct pci_device_id arrays were initialized mostly by one
> the PCI_DEVICE macros and then list expressions. The latter isn't easily
> readable if you're not into PCI. Using named initializers is more
> explicit and thus easier to parse.
>
> Also use PCI_DEVICE* helper macros to assign .vendor, .device,
> .subvendor and .subdevice where appropriate and skip explicit
> assignments of 0 (which the compiler takes care of).
>
> 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 it's also a nice cleanup on
> its own.
>
> This change doesn't introduce changes to the compiled pci_device_id
> arrays. Tested on x86 and arm64.
...
> - {0,} /* 0 terminated list. */
> + { } /* 0 terminated list. */
The comments like these are just noises. The rule of thumb is to play with a
trailing comma:
- always drop it in the terminator entry
- always keep it in the normal initialisers when semantically it's not a
terminator
...
> static const struct pci_device_id liquidio_pci_tbl[] = {
> { /* 68xx */
> - PCI_VENDOR_ID_CAVIUM, 0x91, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0
> + PCI_VDEVICE(CAVIUM, 0x91)
Use full fixed-width device id value(s). 0x0091 here and so on...
> },
Also seems that you may decrease number of LoC here putting it as
{ PCI_VDEVICE(CAVIUM, 0x0091) }, /* 68xx */
and so on...
> { /* 66xx */
> - PCI_VENDOR_ID_CAVIUM, 0x92, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0
> + PCI_VDEVICE(CAVIUM, 0x92)
> },
> { /* 23xx pf */
> - PCI_VENDOR_ID_CAVIUM, 0x9702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0
> + PCI_VDEVICE(CAVIUM, 0x9702)
> },
> - {
> - 0, 0, 0, 0, 0, 0, 0
> - }
> + { }
> };
...
> #define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \
> - { 0, } \
> + { } \
> }
Why do we have this macro at all?
> -#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END { 0, } }
> +#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END { } }
Ditto.
...
> static const struct pci_device_id de_pci_tbl[] = {
> - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
> - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
> - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
> - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
> + { PCI_VDEVICE(DEC, PCI_DEVICE_ID_DEC_TULIP), .driver_data = 0 },
> + { PCI_VDEVICE(DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS), .driver_data = 1 },
> { },
Drop comma. I.o.w. please make sure you also unify the style of the ID tables,
including terminator entries.
> };
...
> static const struct pci_device_id sis190_pci_tbl[] = {
> - { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0190), 0, 0, 0 },
> - { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0191), 0, 0, 1 },
> - { 0, },
> + { PCI_VDEVICE(SI, 0x0190), .driver_data = 0 },
> + { PCI_VDEVICE(SI, 0x0191), .driver_data = 1 },
> + { },
Ditto and so on...
> };
...
Also I somehow managed to remove, but I remember you had an inner comma in some
cases after the .driver_data, when the full ID entry is located on a single
line. I.o.w. do
{ PCI_...(), .driver_data = ... // no trailing comma here! },
When it's a single line trailing comma inside helps nothing and just makes
lines longer and harder to read.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-04-29 6:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 17:18 [PATCH net-next] net: Consistently define pci_device_ids using named initializers Uwe Kleine-König (The Capable Hub)
2026-04-28 19:35 ` Johannes Berg
2026-04-28 22:24 ` Jacob Keller
2026-04-29 6:54 ` Andy Shevchenko [this message]
2026-04-29 10:26 ` Uwe Kleine-König (The Capable Hub)
2026-04-29 8:48 ` Petr Machata
2026-04-29 9:10 ` Marc Kleine-Budde
2026-04-29 10:30 ` Uwe Kleine-König (The Capable Hub)
2026-04-29 9:19 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-04-30 6:53 ` Jijie Shao
2026-04-30 13:13 ` Uwe Kleine-König (The Capable Hub)
2026-04-30 8:55 ` Markus Schneider-Pargmann
2026-04-30 13:15 ` Uwe Kleine-König (The Capable Hub)
2026-04-30 15:14 ` Arend van Spriel
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=afGrPvUeZ-DjWbC8@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=GR-Linux-NIC-Dev@marvell.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arend.vanspriel@broadcom.com \
--cc=benato.denis96@gmail.com \
--cc=bharat@chelsio.com \
--cc=bhelgaas@google.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=cai.huoqing@linux.dev \
--cc=chessman@tux.org \
--cc=chi-hsien.lin@cypress.com \
--cc=colin.i.king@gmail.com \
--cc=danishanwar@ti.com \
--cc=dave@thedillows.org \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=double.lo@cypress.com \
--cc=edumazet@google.com \
--cc=enelsonmoore@gmail.com \
--cc=fourier.thomas@gmail.com \
--cc=gongfan1@huawei.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=ionut@badula.org \
--cc=jacob.e.keller@intel.com \
--cc=jiawenwu@trustnetic.com \
--cc=jiri@resnulli.us \
--cc=joe@dama.to \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=kevin.curtis@farsite.co.uk \
--cc=khc@pm.waw.pl \
--cc=kirjanov@gmail.com \
--cc=klassert@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=leon@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=m.grzeschik@pengutronix.de \
--cc=mailhol@kernel.org \
--cc=manishc@marvell.com \
--cc=marco.crivellari@suse.com \
--cc=mark.einon@gmail.com \
--cc=mbloch@nvidia.com \
--cc=mengyuanlou@net-swift.com \
--cc=mingo@kernel.org \
--cc=mkl@pengutronix.de \
--cc=msp@baylibre.com \
--cc=nathan@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=oss-drivers@corigine.com \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=phasta@kernel.org \
--cc=przemyslaw.kitszel@intel.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=rmody@marvell.com \
--cc=romieu@fr.zoreil.com \
--cc=saeedm@nvidia.com \
--cc=saikrishnag@marvell.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=skalluru@marvell.com \
--cc=stas.yakovlev@gmail.com \
--cc=tariqt@nvidia.com \
--cc=tglx@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=vadim.fedorenko@linux.dev \
--cc=venza@brownhat.org \
--cc=wangpeiyang1@huawei.com \
--cc=yiconghui@gmail.com \
--cc=yyyynoom@gmail.com \
--cc=zilin@seu.edu.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