Re: [PATCH] ata: Consistently define pci_device_ids using named initializers

From: Damien Le Moal

Date: Mon May 04 2026 - 04:14:56 EST


On 4/30/26 19:06, Uwe Kleine-König (The Capable Hub) wrote:
> ... and PCI device helpers.
>
> The .driver_data member in the various struct pci_device_id arrays were
> initialized mostly by list expressions. This 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 to conveniently assign .vendor, .device, .subvendor
> and .subdevice where appropriate.
>
> 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 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@xxxxxxxxxxxx>

This looks like a nice cleanup to me. A couple of nits below.
With that, feel free to add:

Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>

[...]

> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 495fa096dd65..fac1266f7fa6 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -154,184 +154,186 @@ static unsigned int in_module_init = 1;
>
> static const struct pci_device_id piix_pci_tbl[] = {
> /* Intel PIIX3 for the 430HX etc */
> - { 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
> + { PCI_DEVICE(0x8086, 0x7010), .driver_data = piix_pata_mwdma },

Please split the line before the .driver_data like for all the other changes.
That will make things consistent...

> /* VMware ICH4 */
> - { 0x8086, 0x7111, 0x15ad, 0x1976, 0, 0, piix_pata_vmw },
> + { PCI_DEVICE_SUB(0x8086, 0x7111, 0x15ad, 0x1976), .driver_data = piix_pata_vmw },

...and avoid long lines like here.

> + { PCI_DEVICE_SUB(0x8086, 0x2828, 0x106b, 0x00a0), .driver_data = ich8m_apple_sata },
> + { PCI_DEVICE_SUB(0x8086, 0x2828, 0x106b, 0x00a1), .driver_data = ich8m_apple_sata },
> + { PCI_DEVICE_SUB(0x8086, 0x2828, 0x106b, 0x00a3), .driver_data = ich8m_apple_sata },

or here.

> diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
> index a2fecadc927d..b8ae3eb0992b 100644
> --- a/drivers/ata/pata_amd.c
> +++ b/drivers/ata/pata_amd.c
> @@ -597,27 +597,27 @@ static int amd_reinit_one(struct pci_dev *pdev)
> #endif
>
> static const struct pci_device_id amd[] = {
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 3 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 4 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 5 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 7 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 8 },
> - { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 8 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 9 },
> - { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_DEV_IDE), 9 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), .driver_data = 0 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), .driver_data = 1 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), .driver_data = 3 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), .driver_data = 4 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), .driver_data = 5 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), .driver_data = 7 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), .driver_data = 8 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), .driver_data = 9 },
> + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_DEV_IDE), .driver_data = 9 },

same comment here, and for a few other drivers after this.

--
Damien Le Moal
Western Digital Research