drivers/pci/pwrctrl/core.c
Source file repositories/reference/linux-study-clean/drivers/pci/pwrctrl/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pwrctrl/core.c- Extension
.c- Size
- 10129 bytes
- Lines
- 411
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/export.hlinux/kernel.hlinux/of.hlinux/of_graph.hlinux/of_platform.hlinux/pci.hlinux/pci-pwrctrl.hlinux/platform_device.hlinux/property.hlinux/slab.h../pci.h
Detected Declarations
function Copyrightfunction pci_pwrctrl_initfunction pci_pwrctrl_device_set_readyfunction pci_pwrctrl_device_unset_readyfunction devm_pci_pwrctrl_device_unset_readyfunction pci_pwrctrl_device_set_readyfunction __pci_pwrctrl_power_off_devicefunction pci_pwrctrl_power_off_devicefunction pci_pwrctrl_power_off_devicesfunction __pci_pwrctrl_power_on_devicefunction pci_pwrctrl_power_on_devicefunction for_each_available_child_of_node_scopedfunction pci_pwrctrl_power_on_devicesfunction for_each_available_child_of_nodefunction driverfunction pci_pwrctrl_create_devicefunction for_each_available_child_of_node_scopedfunction pci_pwrctrl_create_devicesfunction for_each_available_child_of_node_scopedfunction pci_pwrctrl_destroy_devicefunction pci_pwrctrl_destroy_devicesexport pci_pwrctrl_initexport pci_pwrctrl_device_set_readyexport pci_pwrctrl_device_unset_readyexport devm_pci_pwrctrl_device_set_readyexport pci_pwrctrl_power_off_devicesexport pci_pwrctrl_power_on_devicesexport pci_pwrctrl_create_devicesexport pci_pwrctrl_destroy_devices
Annotated Snippet
for_each_endpoint_of_node(np, endpoint) {
struct device_node *remote __free(device_node) =
of_graph_get_remote_port_parent(endpoint);
if (remote) {
if (of_pci_supply_present(remote)) {
of_node_put(endpoint);
return true;
}
}
}
}
return false;
}
static int pci_pwrctrl_create_device(struct device_node *np,
struct device *parent)
{
struct platform_device *pdev;
int ret;
for_each_available_child_of_node_scoped(np, child) {
ret = pci_pwrctrl_create_device(child, parent);
if (ret)
return ret;
}
/* Bail out if the platform device is already available for the node */
pdev = of_find_device_by_node(np);
if (pdev) {
platform_device_put(pdev);
return 0;
}
if (!pci_pwrctrl_is_required(np)) {
dev_dbg(parent, "Skipping OF node: %s\n", np->name);
return 0;
}
/* Now create the pwrctrl device */
pdev = of_platform_device_create(np, NULL, parent);
if (!pdev) {
dev_err(parent, "Failed to create pwrctrl device for node: %s\n", np->name);
return -EINVAL;
}
return 0;
}
/**
* pci_pwrctrl_create_devices - Create pwrctrl devices
*
* @parent: PCI host controller device
*
* Recursively create pwrctrl devices for the devicetree hierarchy below
* the specified PCI host controller in a depth first manner. On error, all
* created devices will be destroyed.
*
* Return: 0 on success, negative error number on error.
*/
int pci_pwrctrl_create_devices(struct device *parent)
{
int ret;
for_each_available_child_of_node_scoped(parent->of_node, child) {
ret = pci_pwrctrl_create_device(child, parent);
if (ret) {
pci_pwrctrl_destroy_devices(parent);
return ret;
}
}
return 0;
}
EXPORT_SYMBOL_GPL(pci_pwrctrl_create_devices);
static void pci_pwrctrl_destroy_device(struct device_node *np)
{
struct platform_device *pdev;
for_each_available_child_of_node_scoped(np, child)
pci_pwrctrl_destroy_device(child);
pdev = of_find_device_by_node(np);
if (!pdev)
return;
of_device_unregister(pdev);
platform_device_put(pdev);
Annotation
- Immediate include surface: `linux/device.h`, `linux/export.h`, `linux/kernel.h`, `linux/of.h`, `linux/of_graph.h`, `linux/of_platform.h`, `linux/pci.h`, `linux/pci-pwrctrl.h`.
- Detected declarations: `function Copyright`, `function pci_pwrctrl_init`, `function pci_pwrctrl_device_set_ready`, `function pci_pwrctrl_device_unset_ready`, `function devm_pci_pwrctrl_device_unset_ready`, `function pci_pwrctrl_device_set_ready`, `function __pci_pwrctrl_power_off_device`, `function pci_pwrctrl_power_off_device`, `function pci_pwrctrl_power_off_devices`, `function __pci_pwrctrl_power_on_device`.
- 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.