mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	 Andy Shevchenko <andy@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	 Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	 linux-kernel@vger.kernel.org,
	Markus Schneider-Pargmann <msp@baylibre.com>
Subject: Re: [PATCH] x86/platform/intel-mid: Use named initializer for pci_device_id array
Date: Fri, 17 Jul 2026 11:44:26 +0200	[thread overview]
Message-ID: <aln2f8snntQFkxAi@monoceros> (raw)
In-Reply-To: <af7yKdRdDSJjkoIk@monoceros>

[-- Attachment #1: Type: text/plain, Size: 3580 bytes --]

Hello Andy,

On Sat, May 09, 2026 at 03:42:44PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> > My point is to put all burden in one place
> > id est PCI_DEVICE_DATA() macro, your point is to spread a churn all over
> > the kernel which I disagree with.
> 
> In my approach the first step (U1) is:
> 
> 	 static const struct pci_device_id mid_pwr_pci_ids[] = {
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), (kernel_ulong_t)&pnw_info },
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), (kernel_ulong_t)&tng_info },
> 	+        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), .driver_data = (kernel_ulong_t)&pnw_info },
> 	+        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), .driver_data = (kernel_ulong_t)&tng_info },
> 		 {}
> 	 };
> 
> (i.e. the patch under discussion) and the second (U2) is
> 
> 	 static int mid_pwr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> 	 {
> 	-	struct mid_pwr_device_info *info = (void *)id->driver_data;
> 	+	const struct mid_pwr_device_info *info = id->driver_data_ptr;
> 		struct device *dev = &pdev->dev;
> 		struct mid_pwr *pwr;
> 		int ret;
> 	...
> 	 static const struct pci_device_id mid_pwr_pci_ids[] = {
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), .driver_data = (kernel_ulong_t)&pnw_info },
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), .driver_data = (kernel_ulong_t)&tng_info },
> 	+        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), .driver_data_ptr = &pnw_info },
> 	+        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), .driver_data_ptr = &tng_info },
> 		 {}
> 	 };
> 
> . With your suggested approach we have instead of U1 the following (A1):
> 
> 	 static const struct pci_device_id mid_pwr_pci_ids[] = {
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), (kernel_ulong_t)&pnw_info },
> 	-        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), (kernel_ulong_t)&tng_info },
> 	+        { PCI_DEVICE_DATA(INTEL, PENWELL), &pnw_info) },
> 	+        { PCI_DEVICE_DATA(INTEL, TANGIER), &tng_info) },
> 		 {}
> 	 };
> 
> and to benefit later from the union there is still the first hunk of U2
> needed (A2):
> 
> 	 static int mid_pwr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> 	 {
> 	-	struct mid_pwr_device_info *info = (void *)id->driver_data;
> 	+	const struct mid_pwr_device_info *info = id->driver_data_ptr;
> 		struct device *dev = &pdev->dev;
> 		struct mid_pwr *pwr;
> 		int ret;
> 
> . I was under the impression you assumed there is no need for A2, but
> that's wrong. Additionally U2 is easier to review and judge that is
> correct than A2 because it uses an indirection less, while A2 depends on
> .driver_data and .driver_data_ptr holding the same data. With my
> approach there is always a directly visible 1:1 correspondance between
> the array and the probe function.
> 
> Also if A2 at a later point is backported to stable it applies just fine
> without A1 and the _Generic extention of PCI_DEVICE_DATA() and the added
> union. With my approach it's more obvious that you also need U1 before
> you can apply U2. (Yes, it still doesn't fail to apply without the added
> union to pci_device_id, but that's three potential papercuts with your
> approach vs. one with mine.)
> 
> So I don't buy your argument that A1 + A2 is less churn than U1 + U2. In
> my book U1 + U2 is even less.

You stopped replying to this discussion after my argumentation. Does
that mean I managed to convince you?

In that case, please consider applying the patch.

Thanks
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-07-17  9:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 15:40 Uwe Kleine-König (The Capable Hub)
2026-05-07 17:24 ` Andy Shevchenko
2026-05-08  6:25   ` Uwe Kleine-König (The Capable Hub)
2026-05-08  7:15     ` Andy Shevchenko
2026-05-08 10:49       ` Uwe Kleine-König (The Capable Hub)
2026-05-09  6:35         ` Andy Shevchenko
2026-05-09 13:42           ` Uwe Kleine-König (The Capable Hub)
2026-07-17  9:44             ` Uwe Kleine-König (The Capable Hub) [this message]
2026-07-17 10:19               ` Andy Shevchenko

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=aln2f8snntQFkxAi@monoceros \
    --to=u.kleine-koenig@baylibre.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=msp@baylibre.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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

Powered by JetHome