aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/bus.c32
-rw-r--r--include/linux/pci.h2
2 files changed, 29 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/**
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 4c16a5788998..9daa79901122 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -917,6 +917,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
917void pci_release_selected_regions(struct pci_dev *, int); 917void pci_release_selected_regions(struct pci_dev *, int);
918 918
919/* drivers/pci/bus.c */ 919/* drivers/pci/bus.c */
920void pci_add_resource(struct list_head *resources, struct resource *res);
921void pci_free_resource_list(struct list_head *resources);
920void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags); 922void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
921struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n); 923struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
922void pci_bus_remove_resources(struct pci_bus *bus); 924void pci_bus_remove_resources(struct pci_bus *bus);