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>
This commit is contained in:
Родитель
afd24ece5c
Коммит
45ca9e9730
|
@ -18,6 +18,32 @@
|
||||||
|
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
|
|
||||||
|
void pci_add_resource(struct list_head *resources, struct resource *res)
|
||||||
|
{
|
||||||
|
struct pci_bus_resource *bus_res;
|
||||||
|
|
||||||
|
bus_res = kzalloc(sizeof(struct pci_bus_resource), GFP_KERNEL);
|
||||||
|
if (!bus_res) {
|
||||||
|
printk(KERN_ERR "PCI: can't add bus resource %pR\n", res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bus_res->res = res;
|
||||||
|
list_add_tail(&bus_res->list, resources);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(pci_add_resource);
|
||||||
|
|
||||||
|
void pci_free_resource_list(struct list_head *resources)
|
||||||
|
{
|
||||||
|
struct pci_bus_resource *bus_res, *tmp;
|
||||||
|
|
||||||
|
list_for_each_entry_safe(bus_res, tmp, resources, list) {
|
||||||
|
list_del(&bus_res->list);
|
||||||
|
kfree(bus_res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(pci_free_resource_list);
|
||||||
|
|
||||||
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
|
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
@ -52,16 +78,12 @@ EXPORT_SYMBOL_GPL(pci_bus_resource_n);
|
||||||
|
|
||||||
void pci_bus_remove_resources(struct pci_bus *bus)
|
void pci_bus_remove_resources(struct pci_bus *bus)
|
||||||
{
|
{
|
||||||
struct pci_bus_resource *bus_res, *tmp;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
|
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
|
||||||
bus->resource[i] = NULL;
|
bus->resource[i] = NULL;
|
||||||
|
|
||||||
list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
|
pci_free_resource_list(&bus->resources);
|
||||||
list_del(&bus_res->list);
|
|
||||||
kfree(bus_res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -917,6 +917,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
|
||||||
void pci_release_selected_regions(struct pci_dev *, int);
|
void pci_release_selected_regions(struct pci_dev *, int);
|
||||||
|
|
||||||
/* drivers/pci/bus.c */
|
/* drivers/pci/bus.c */
|
||||||
|
void pci_add_resource(struct list_head *resources, struct resource *res);
|
||||||
|
void pci_free_resource_list(struct list_head *resources);
|
||||||
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
|
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, unsigned int flags);
|
||||||
struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
|
struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
|
||||||
void pci_bus_remove_resources(struct pci_bus *bus);
|
void pci_bus_remove_resources(struct pci_bus *bus);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче