All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Damien Le Moal <dlemoal@kernel.org>,
	Niklas Cassel <cassel@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 16:29:04 +0100	[thread overview]
Message-ID: <20260612162904.396dbc1f@pumpkin> (raw)
In-Reply-To: <616e527a0c6cd367f3301438501d8345b0675df1.1781252168.git.ukleinek@kernel.org>

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.

-- David



  parent reply	other threads:[~2026-06-12 15:29 UTC|newest]

Thread overview: 6+ 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 [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=20260612162904.396dbc1f@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=cassel@kernel.org \
    --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.