diff options
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/host-bridge.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 28b24a5375d4..c49a1c482cfb 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c | |||
@@ -16,15 +16,22 @@ void add_to_pci_host_bridges(struct pci_host_bridge *bridge) | |||
16 | list_add_tail(&bridge->list, &pci_host_bridges); | 16 | list_add_tail(&bridge->list, &pci_host_bridges); |
17 | } | 17 | } |
18 | 18 | ||
19 | static struct pci_host_bridge *pci_host_bridge(struct pci_dev *dev) | 19 | static struct pci_bus *find_pci_root_bus(struct pci_dev *dev) |
20 | { | 20 | { |
21 | struct pci_bus *bus; | 21 | struct pci_bus *bus; |
22 | struct pci_host_bridge *bridge; | ||
23 | 22 | ||
24 | bus = dev->bus; | 23 | bus = dev->bus; |
25 | while (bus->parent) | 24 | while (bus->parent) |
26 | bus = bus->parent; | 25 | bus = bus->parent; |
27 | 26 | ||
27 | return bus; | ||
28 | } | ||
29 | |||
30 | static struct pci_host_bridge *find_pci_host_bridge(struct pci_dev *dev) | ||
31 | { | ||
32 | struct pci_bus *bus = find_pci_root_bus(dev); | ||
33 | struct pci_host_bridge *bridge; | ||
34 | |||
28 | list_for_each_entry(bridge, &pci_host_bridges, list) { | 35 | list_for_each_entry(bridge, &pci_host_bridges, list) { |
29 | if (bridge->bus == bus) | 36 | if (bridge->bus == bus) |
30 | return bridge; | 37 | return bridge; |
@@ -41,7 +48,7 @@ static bool resource_contains(struct resource *res1, struct resource *res2) | |||
41 | void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, | 48 | void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, |
42 | struct resource *res) | 49 | struct resource *res) |
43 | { | 50 | { |
44 | struct pci_host_bridge *bridge = pci_host_bridge(dev); | 51 | struct pci_host_bridge *bridge = find_pci_host_bridge(dev); |
45 | struct pci_host_bridge_window *window; | 52 | struct pci_host_bridge_window *window; |
46 | resource_size_t offset = 0; | 53 | resource_size_t offset = 0; |
47 | 54 | ||
@@ -69,12 +76,13 @@ static bool region_contains(struct pci_bus_region *region1, | |||
69 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, | 76 | void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res, |
70 | struct pci_bus_region *region) | 77 | struct pci_bus_region *region) |
71 | { | 78 | { |
72 | struct pci_host_bridge *bridge = pci_host_bridge(dev); | 79 | struct pci_host_bridge *bridge = find_pci_host_bridge(dev); |
73 | struct pci_host_bridge_window *window; | 80 | struct pci_host_bridge_window *window; |
74 | struct pci_bus_region bus_region; | ||
75 | resource_size_t offset = 0; | 81 | resource_size_t offset = 0; |
76 | 82 | ||
77 | list_for_each_entry(window, &bridge->windows, list) { | 83 | list_for_each_entry(window, &bridge->windows, list) { |
84 | struct pci_bus_region bus_region; | ||
85 | |||
78 | if (resource_type(res) != resource_type(window->res)) | 86 | if (resource_type(res) != resource_type(window->res)) |
79 | continue; | 87 | continue; |
80 | 88 | ||