Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: add host bridge release support

We need a hook to release host bridge resources allocated when creating
root bus.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Yinghai Lu and committed by
Bjorn Helgaas
4fa2649a 7b543663

+15 -1
+8
drivers/pci/host-bridge.c
··· 27 27 return to_pci_host_bridge(bus->bridge); 28 28 } 29 29 30 + void pci_set_host_bridge_release(struct pci_host_bridge *bridge, 31 + void (*release_fn)(struct pci_host_bridge *), 32 + void *release_data) 33 + { 34 + bridge->release_fn = release_fn; 35 + bridge->release_data = release_data; 36 + } 37 + 30 38 static bool resource_contains(struct resource *res1, struct resource *res2) 31 39 { 32 40 return res1->start <= res2->start && res1->end >= res2->end;
+2 -1
drivers/pci/probe.c
··· 1137 1137 { 1138 1138 struct pci_host_bridge *bridge = to_pci_host_bridge(dev); 1139 1139 1140 - /* TODO: need to free window->res */ 1140 + if (bridge->release_fn) 1141 + bridge->release_fn(bridge); 1141 1142 1142 1143 pci_free_resource_list(&bridge->windows); 1143 1144
+5
include/linux/pci.h
··· 378 378 struct device dev; 379 379 struct pci_bus *bus; /* root bus */ 380 380 struct list_head windows; /* pci_host_bridge_windows */ 381 + void (*release_fn)(struct pci_host_bridge *); 382 + void *release_data; 381 383 }; 382 384 383 385 #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) 386 + void pci_set_host_bridge_release(struct pci_host_bridge *bridge, 387 + void (*release_fn)(struct pci_host_bridge *), 388 + void *release_data); 384 389 385 390 /* 386 391 * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond