drivers/pci/bus.c
Source file repositories/reference/linux-study-clean/drivers/pci/bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/bus.c- Extension
.c- Size
- 12502 bytes
- Lines
- 506
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/cleanup.hlinux/pci.hlinux/errno.hlinux/ioport.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/pm_runtime.hlinux/proc_fs.hlinux/slab.hpci.h
Detected Declarations
struct pci_bus_resourcefunction pci_add_resource_offsetfunction pci_add_resourcefunction pci_free_resource_listfunction pci_bus_add_resourcefunction pci_bus_remove_resourcefunction list_for_each_entry_safefunction pci_bus_remove_resourcesfunction list_for_each_entry_safefunction devm_request_pci_bus_resourcesfunction resource_list_for_each_entryfunction pci_clip_resource_to_regionfunction pci_bus_alloc_from_regionfunction pci_bus_for_each_resourcefunction pci_bus_alloc_resourcefunction pci_bus_clip_resourcefunction pci_bus_for_each_resourcefunction pcibios_resource_survey_busfunction pci_bus_add_devicesfunction list_for_each_entryfunction list_for_each_entryfunction __pci_walk_busfunction list_for_each_entryfunction __pci_walk_bus_reversefunction list_for_each_entry_reversefunction pci_walk_busfunction pci_walk_busfunction pci_walk_bus_lockedfunction pci_bus_putexport pci_add_resource_offsetexport pci_add_resourceexport pci_free_resource_listexport pci_bus_resource_nexport devm_request_pci_bus_resourcesexport pci_bus_alloc_resourceexport pci_bus_add_deviceexport pci_bus_add_devicesexport pci_walk_busexport pci_walk_bus_reverse
Annotated Snippet
struct pci_bus_resource {
struct list_head list;
struct resource *res;
};
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
resource_size_t offset)
{
struct resource_entry *entry;
entry = resource_list_create_entry(res, 0);
if (!entry) {
pr_err("PCI: can't add host bridge window %pR\n", res);
return;
}
entry->offset = offset;
resource_list_add_tail(entry, resources);
}
EXPORT_SYMBOL(pci_add_resource_offset);
void pci_add_resource(struct list_head *resources, struct resource *res)
{
pci_add_resource_offset(resources, res, 0);
}
EXPORT_SYMBOL(pci_add_resource);
void pci_free_resource_list(struct list_head *resources)
{
resource_list_free(resources);
}
EXPORT_SYMBOL(pci_free_resource_list);
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res)
{
struct pci_bus_resource *bus_res;
bus_res = kzalloc_obj(struct pci_bus_resource);
if (!bus_res) {
dev_err(&bus->dev, "can't add %pR resource\n", res);
return;
}
bus_res->res = res;
list_add_tail(&bus_res->list, &bus->resources);
}
struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n)
{
struct pci_bus_resource *bus_res;
if (n < PCI_BRIDGE_RESOURCE_NUM)
return bus->resource[n];
n -= PCI_BRIDGE_RESOURCE_NUM;
list_for_each_entry(bus_res, &bus->resources, list) {
if (n-- == 0)
return bus_res->res;
}
return NULL;
}
EXPORT_SYMBOL_GPL(pci_bus_resource_n);
void pci_bus_remove_resource(struct pci_bus *bus, struct resource *res)
{
struct pci_bus_resource *bus_res, *tmp;
int i;
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
if (bus->resource[i] == res) {
bus->resource[i] = NULL;
return;
}
}
list_for_each_entry_safe(bus_res, tmp, &bus->resources, list) {
if (bus_res->res == res) {
list_del(&bus_res->list);
kfree(bus_res);
return;
}
}
}
void pci_bus_remove_resources(struct pci_bus *bus)
{
int i;
struct pci_bus_resource *bus_res, *tmp;
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/cleanup.h`, `linux/pci.h`, `linux/errno.h`, `linux/ioport.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `struct pci_bus_resource`, `function pci_add_resource_offset`, `function pci_add_resource`, `function pci_free_resource_list`, `function pci_bus_add_resource`, `function pci_bus_remove_resource`, `function list_for_each_entry_safe`, `function pci_bus_remove_resources`, `function list_for_each_entry_safe`, `function devm_request_pci_bus_resources`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.