All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/platform/intel-mid: Use named initializer for pci_device_id array
@ 2026-05-07 15:40 Uwe Kleine-König (The Capable Hub)
  2026-05-07 17:24 ` Andy Shevchenko
  2026-11-25 13:56 ` Uwe Kleine-König (The Capable Hub)
  0 siblings, 2 replies; 10+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-07 15:40 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, linux-kernel, Markus Schneider-Pargmann

While being more verbose using a named initializer yields easier to
understand code and doesn't rely on the two hidden zeros in the
PCI_VDEVICE macro.

This doesn't introduce any changes to the compiled result of the array,
which was confirmed with an ARCH=x86 build.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
Hello,

while being a cleanup that can stand on its own this is also a
preparation for making driver_data an anonymous union that requires that
.driver_data is initialized by name and not by list order. The union
allows to make better use of the C type system and drops the need for
casting which then let the compiler notice a missing const. The change
to the driver will look as follows:

	diff --git a/arch/x86/platform/intel-mid/pwr.c b/arch/x86/platform/intel-mid/pwr.c
	index 1739971478ff..f677d30b4342 100644
	--- a/arch/x86/platform/intel-mid/pwr.c
	+++ b/arch/x86/platform/intel-mid/pwr.c
	@@ -347,7 +347,7 @@ struct mid_pwr_device_info {

	 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;
	@@ -471,8 +471,8 @@ static const struct mid_pwr_device_info tng_info = {

	 /* This table should be in sync with the one in drivers/pci/pci-mid.c */
	 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 },
		{}
	 };

Best regards
Uwe

 arch/x86/platform/intel-mid/pwr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/intel-mid/pwr.c b/arch/x86/platform/intel-mid/pwr.c
index cd7e0c71adde..1739971478ff 100644
--- a/arch/x86/platform/intel-mid/pwr.c
+++ b/arch/x86/platform/intel-mid/pwr.c
@@ -471,8 +471,8 @@ static const struct mid_pwr_device_info tng_info = {
 
 /* This table should be in sync with the one in drivers/pci/pci-mid.c */
 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 },
 	{}
 };
 

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-25 13:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 15:40 [PATCH] x86/platform/intel-mid: Use named initializer for pci_device_id array 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)
2026-07-17 10:19               ` Andy Shevchenko
2026-11-25 13:56 ` Uwe Kleine-König (The Capable Hub)

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.