Skip to content

Commit ebbebd8

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Add pci_setup_one_bridge_window()
pci_bridge_release_resources() contains a resource type hack to work around the unsuitable __pci_setup_bridge() interface. Extract the switch statement that picks the correct bridge window setup function from pci_claim_bridge_resource() into pci_setup_one_bridge_window() and use it also in pci_bridge_release_resources(). 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-23-ilpo.jarvinen@linux.intel.com
1 parent aaae286 commit ebbebd8

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

drivers/pci/setup-bus.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,23 @@ static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type)
953953
pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
954954
}
955955

956+
static void pci_setup_one_bridge_window(struct pci_dev *bridge, int resno)
957+
{
958+
switch (resno) {
959+
case PCI_BRIDGE_IO_WINDOW:
960+
pci_setup_bridge_io(bridge);
961+
break;
962+
case PCI_BRIDGE_MEM_WINDOW:
963+
pci_setup_bridge_mmio(bridge);
964+
break;
965+
case PCI_BRIDGE_PREF_MEM_WINDOW:
966+
pci_setup_bridge_mmio_pref(bridge);
967+
break;
968+
default:
969+
return;
970+
}
971+
}
972+
956973
void __weak pcibios_setup_bridge(struct pci_bus *bus, unsigned long type)
957974
{
958975
}
@@ -987,19 +1004,7 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
9871004
if (pci_bus_clip_resource(bridge, i))
9881005
ret = pci_claim_resource(bridge, i);
9891006

990-
switch (i) {
991-
case PCI_BRIDGE_IO_WINDOW:
992-
pci_setup_bridge_io(bridge);
993-
break;
994-
case PCI_BRIDGE_MEM_WINDOW:
995-
pci_setup_bridge_mmio(bridge);
996-
break;
997-
case PCI_BRIDGE_PREF_MEM_WINDOW:
998-
pci_setup_bridge_mmio_pref(bridge);
999-
break;
1000-
default:
1001-
return -EINVAL;
1002-
}
1007+
pci_setup_one_bridge_window(bridge, i);
10031008

10041009
return ret;
10051010
}
@@ -1839,11 +1844,7 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
18391844
if (ret)
18401845
return;
18411846

1842-
type = r->flags & PCI_RES_TYPE_MASK;
1843-
/* Avoiding touch the one without PREF */
1844-
if (type & IORESOURCE_PREFETCH)
1845-
type = IORESOURCE_PREFETCH;
1846-
__pci_setup_bridge(bus, type);
1847+
pci_setup_one_bridge_window(dev, PCI_BRIDGE_RESOURCES + idx);
18471848
}
18481849

18491850
enum release_type {

0 commit comments

Comments
 (0)