Skip to content

Commit e493483

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Add defines for bridge window indexing
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
1 parent 8278c69 commit e493483

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/pci/pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ struct pcie_tlp_log;
8181
#define PCIE_MSG_CODE_DEASSERT_INTC 0x26
8282
#define PCIE_MSG_CODE_DEASSERT_INTD 0x27
8383

84+
#define PCI_BUS_BRIDGE_IO_WINDOW 0
85+
#define PCI_BUS_BRIDGE_MEM_WINDOW 1
86+
#define PCI_BUS_BRIDGE_PREF_MEM_WINDOW 2
87+
8488
extern const unsigned char pcie_link_speed[];
8589
extern bool pci_early_dump;
8690

drivers/pci/probe.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,13 @@ void pci_read_bridge_bases(struct pci_bus *child)
598598
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
599599
child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i];
600600

601-
pci_read_bridge_io(child->self, child->resource[0], false);
602-
pci_read_bridge_mmio(child->self, child->resource[1], false);
603-
pci_read_bridge_mmio_pref(child->self, child->resource[2], false);
601+
pci_read_bridge_io(child->self,
602+
child->resource[PCI_BUS_BRIDGE_IO_WINDOW], false);
603+
pci_read_bridge_mmio(child->self,
604+
child->resource[PCI_BUS_BRIDGE_MEM_WINDOW], false);
605+
pci_read_bridge_mmio_pref(child->self,
606+
child->resource[PCI_BUS_BRIDGE_PREF_MEM_WINDOW],
607+
false);
604608

605609
if (!dev->transparent)
606610
return;

0 commit comments

Comments
 (0)