]> www.infradead.org Git - users/hch/misc.git/commitdiff
PCI: Add defines for bridge window indexing
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 29 Aug 2025 13:11:00 +0000 (16:11 +0300)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 16 Sep 2025 16:19:24 +0000 (11:19 -0500)
include/linux/pci.h provides PCI_BRIDGE_{IO,MEM,PREF_MEM}_WINDOW defines,
however, they're based on the resource array indexing in the pci_dev
struct. The struct pci_bus also has pointers to those same resources but
they start from zeroth index.

Add PCI_BUS_BRIDGE_{IO,MEM,PREF_MEM}_WINDOW defines to get rid of literal
indexing.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250829131113.36754-12-ilpo.jarvinen@linux.intel.com
drivers/pci/pci.h
drivers/pci/probe.c

index 34f65d69662e9f61f0c489ec58de2ce17d21c0c6..1dc8a806676194c026db8cddc4d18694a81c7dc6 100644 (file)
@@ -81,6 +81,10 @@ struct pcie_tlp_log;
 #define PCIE_MSG_CODE_DEASSERT_INTC    0x26
 #define PCIE_MSG_CODE_DEASSERT_INTD    0x27
 
+#define PCI_BUS_BRIDGE_IO_WINDOW       0
+#define PCI_BUS_BRIDGE_MEM_WINDOW      1
+#define PCI_BUS_BRIDGE_PREF_MEM_WINDOW 2
+
 extern const unsigned char pcie_link_speed[];
 extern bool pci_early_dump;
 
index f31d27c7708a667291b98763c37c4a737e569a9f..eaeb66bec433b0d0dc7935d0df372119ac7c76ad 100644 (file)
@@ -598,9 +598,13 @@ void pci_read_bridge_bases(struct pci_bus *child)
        for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
                child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i];
 
-       pci_read_bridge_io(child->self, child->resource[0], false);
-       pci_read_bridge_mmio(child->self, child->resource[1], false);
-       pci_read_bridge_mmio_pref(child->self, child->resource[2], false);
+       pci_read_bridge_io(child->self,
+                          child->resource[PCI_BUS_BRIDGE_IO_WINDOW], false);
+       pci_read_bridge_mmio(child->self,
+                            child->resource[PCI_BUS_BRIDGE_MEM_WINDOW], false);
+       pci_read_bridge_mmio_pref(child->self,
+                                 child->resource[PCI_BUS_BRIDGE_PREF_MEM_WINDOW],
+                                 false);
 
        if (!dev->transparent)
                return;