drivers/pci/of.c
Source file repositories/reference/linux-study-clean/drivers/pci/of.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/of.c- Extension
.c- Size
- 26364 bytes
- Lines
- 1009
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cleanup.hlinux/irqdomain.hlinux/kernel.hlinux/pci.hlinux/of.hlinux/of_irq.hlinux/of_address.hlinux/of_pci.hlinux/platform_device.hpci.h
Detected Declarations
function pci_set_of_nodefunction pci_release_of_nodefunction pci_set_bus_of_nodefunction pci_release_bus_of_nodefunction pcibios_get_phb_of_nodefunction pci_host_of_has_msi_mapfunction __of_pci_pci_comparefunction for_each_child_of_nodefunction of_pci_get_devfnfunction of_pci_parse_bus_rangefunction of_get_pci_domain_nrfunction of_pci_preserve_configfunction of_pci_check_probe_onlyfunction devm_of_pci_get_host_bridge_resourcesfunction of_irq_parse_pcifunction pci_assign_irqfunction pci_parse_request_of_pci_rangesfunction resource_list_for_each_entry_safefunction devm_of_pci_bridge_initfunction of_pci_remove_nodefunction of_pci_make_dev_nodefunction of_pci_remove_host_bridge_nodefunction of_pci_make_host_bridge_nodefunction of_pci_supply_presentfunction for_each_property_of_nodefunction of_pci_get_max_link_speedfunction of_pci_get_slot_power_limitfunction of_pci_get_equalization_presetsexport of_pci_find_child_deviceexport of_pci_get_devfnexport of_get_pci_domain_nrexport of_pci_check_probe_onlyexport of_irq_parse_and_map_pciexport of_pci_supply_presentexport of_pci_get_max_link_speedexport of_pci_get_slot_power_limitexport of_pci_get_equalization_presets
Annotated Snippet
if (of_node_name_eq(node, "multifunc-device")) {
for_each_child_of_node(node, node2) {
if (__of_pci_pci_compare(node2, devfn)) {
of_node_put(node);
return node2;
}
}
}
}
return NULL;
}
EXPORT_SYMBOL_GPL(of_pci_find_child_device);
/**
* of_pci_get_devfn() - Get device and function numbers for a device node
* @np: device node
*
* Parses a standard 5-cell PCI resource and returns an 8-bit value that can
* be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device
* and function numbers respectively. On error a negative error code is
* returned.
*/
int of_pci_get_devfn(struct device_node *np)
{
u32 reg[5];
int error;
error = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg));
if (error)
return error;
return (reg[0] >> 8) & 0xff;
}
EXPORT_SYMBOL_GPL(of_pci_get_devfn);
/**
* of_pci_parse_bus_range() - parse the bus-range property of a PCI device
* @node: device node
* @res: address to a struct resource to return the bus-range
*
* Returns 0 on success or a negative error-code on failure.
*/
static int of_pci_parse_bus_range(struct device_node *node,
struct resource *res)
{
u32 bus_range[2];
int error;
error = of_property_read_u32_array(node, "bus-range", bus_range,
ARRAY_SIZE(bus_range));
if (error)
return error;
res->name = node->name;
res->start = bus_range[0];
res->end = bus_range[1];
res->flags = IORESOURCE_BUS;
return 0;
}
/**
* of_get_pci_domain_nr - Find the host bridge domain number
* of the given device node.
* @node: Device tree node with the domain information.
*
* This function will try to obtain the host bridge domain number by finding
* a property called "linux,pci-domain" of the given device node.
*
* Return:
* * > 0 - On success, an associated domain number.
* * -EINVAL - The property "linux,pci-domain" does not exist.
* * -ENODATA - The linux,pci-domain" property does not have value.
* * -EOVERFLOW - Invalid "linux,pci-domain" property value.
*
* Returns the associated domain number from DT in the range [0-0xffff], or
* a negative value if the required property is not found.
*/
int of_get_pci_domain_nr(struct device_node *node)
{
u32 domain;
int error;
error = of_property_read_u32(node, "linux,pci-domain", &domain);
if (error)
return error;
return (u16)domain;
}
EXPORT_SYMBOL_GPL(of_get_pci_domain_nr);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/pci.h`, `linux/of.h`, `linux/of_irq.h`, `linux/of_address.h`, `linux/of_pci.h`.
- Detected declarations: `function pci_set_of_node`, `function pci_release_of_node`, `function pci_set_bus_of_node`, `function pci_release_bus_of_node`, `function pcibios_get_phb_of_node`, `function pci_host_of_has_msi_map`, `function __of_pci_pci_compare`, `function for_each_child_of_node`, `function of_pci_get_devfn`, `function of_pci_parse_bus_range`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.