[PATCH] xen/platform-pci: Simplify initialization of pci_device_id array

Uwe Kleine-König (The Capable Hub) posted 1 patch 1 week, 1 day ago
Failed in applying to current master (apply log)
There is a newer version of this series
drivers/xen/platform-pci.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] xen/platform-pci: Simplify initialization of pci_device_id array
Posted by Uwe Kleine-König (The Capable Hub) 1 week, 1 day ago
Instead of using a list initializer---that is hard to read unless you know
the structure of struct pci_device_id by heart---use the PCI_VDEVICE
macro to assign the needed values and drop all explicit but unneeded
zeros.

This doesn't introduce any changes to the compiled result of the array.

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

this is a preparing change for making struct pci_device_id::driver_data
an anonymous union (similar to
https://lore.kernel.org/all/cover.1776579304.git.u.kleine-koenig@baylibre.com/).
This requires named initializers for .driver_data. Dropping the unused
assignment is still better.

Best regards
Uwe

 drivers/xen/platform-pci.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/xen/platform-pci.c b/drivers/xen/platform-pci.c
index 1db82da56db6..f2438232518c 100644
--- a/drivers/xen/platform-pci.c
+++ b/drivers/xen/platform-pci.c
@@ -174,11 +174,9 @@ static int platform_pci_probe(struct pci_dev *pdev,
 }
 
 static const struct pci_device_id platform_pci_tbl[] = {
-	{PCI_VENDOR_ID_XEN, PCI_DEVICE_ID_XEN_PLATFORM,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_XEN, PCI_DEVICE_ID_XEN_PLATFORM_XS61,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0,}
+	{ PCI_VDEVICE(XEN, PCI_DEVICE_ID_XEN_PLATFORM) },
+	{ PCI_VDEVICE(XEN, PCI_DEVICE_ID_XEN_PLATFORM_XS61) },
+	{ }
 };
 
 static const struct dev_pm_ops platform_pm_ops = {

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
-- 
2.47.3

Re: [PATCH] xen/platform-pci: Simplify initialization of pci_device_id array
Posted by Jürgen Groß 1 week, 1 day ago
On 05.05.26 12:29, Uwe Kleine-König (The Capable Hub) wrote:
> Instead of using a list initializer---that is hard to read unless you know
> the structure of struct pci_device_id by heart---use the PCI_VDEVICE
> macro to assign the needed values and drop all explicit but unneeded
> zeros.
> 
> This doesn't introduce any changes to the compiled result of the array.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen