aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2011-10-28 18:25:35 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2012-01-06 15:10:50 -0500
commit45ca9e9730c5acdb482dd95799fd8ac834481897 (patch)
treeb73836ea44c0b3537ededd0c86653edfcfabb5c3 /drivers
parentafd24ece5c76af87f6fc477f2747b83a764f161c (diff)
PCI: add helpers for building PCI bus resource lists
We'd like to supply a list of resources when we create a new PCI bus, e.g., the root bus under a PCI host bridge. These are helpers for constructing that list. These are exported because the plan is to replace this exported interface: pci_scan_bus_parented() with this one: pci_add_resource(resources, ...) pci_scan_root_bus(..., resources) Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/bus.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 1e2ad92a4752..398f5d859791 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -18,6 +18,32 @@
18 18
19#include "pci.h" 19#include "pci.h"
20 20
21void pci_add_resource(struct list_head *resources, struct resource *res)
22{
23 struct pci_bus_resource *bus_res;
24
25 bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
26 if (!bus_res) {
27 printk(KERN_ERR "PCI: can't add bus resource %pR\n", res);
28 return;
29 }
30
31 bus_res->res = res;
32 list_add_tail(&bus_res->list, resources);
33}
34EXPORT_SYMBOL(pci_add_resource);
35
36void pci_free_resource_list(struct list_head *resources)
37{
38 struct pci_bus_resource *bus_res, *tmp;
39
40 list_for_each_entry_safe(bus_res, tmp, resources, list) {
41 list_del(&bus_res->list);
42 kfree(bus_res);
43 }
44}
45EXPORT_SYMBOL(pci_free_resource_list);
46
21void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, 47void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
22 unsigned int flags) 48 unsigned int flags)
23{ 49{
@@ -52,16 +78,12 @@ EXPORT_SYMBOL_GPL(pci_bus_resource_n);
52 78
53void pci_bus_remove_resources(struct pci_bus *bus) 79void pci_bus_remove_resources(struct pci_bus *bus)
54{ 80{
55 struct pci_bus_resource *bus_res, *tmp;
56 int i; 81 int i;
57 82
58 for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) 83 for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
59 bus->resource[i] = NULL; 84 bus->resource[i] = NULL;
60 85
61 list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) { 86 pci_free_resource_list(&bus->resources);
62 list_del(&bus_res->list);
63 kfree(bus_res);
64 }
65} 87}
66 88
67/** 89/**