drivers/pci/pwrctrl/generic.c
Source file repositories/reference/linux-study-clean/drivers/pci/pwrctrl/generic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/pwrctrl/generic.c- Extension
.c- Size
- 3432 bytes
- Lines
- 141
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: implementation source
- Status
- source 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.
- 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/clk.hlinux/device.hlinux/mod_devicetable.hlinux/module.hlinux/of_graph.hlinux/pci-pwrctrl.hlinux/platform_device.hlinux/pwrseq/consumer.hlinux/regulator/consumer.hlinux/slab.h
Detected Declarations
struct slot_pwrctrlfunction slot_pwrctrl_power_onfunction slot_pwrctrl_power_offfunction devm_slot_pwrctrl_releasefunction slot_pwrctrl_probe
Annotated Snippet
struct slot_pwrctrl {
struct pci_pwrctrl pwrctrl;
struct regulator_bulk_data *supplies;
int num_supplies;
struct clk *clk;
struct pwrseq_desc *pwrseq;
};
static int slot_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl)
{
struct slot_pwrctrl *slot = container_of(pwrctrl,
struct slot_pwrctrl, pwrctrl);
int ret;
if (slot->pwrseq) {
pwrseq_power_on(slot->pwrseq);
return 0;
}
ret = regulator_bulk_enable(slot->num_supplies, slot->supplies);
if (ret < 0) {
dev_err(slot->pwrctrl.dev, "Failed to enable slot regulators\n");
return ret;
}
return clk_prepare_enable(slot->clk);
}
static int slot_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl)
{
struct slot_pwrctrl *slot = container_of(pwrctrl,
struct slot_pwrctrl, pwrctrl);
if (slot->pwrseq) {
pwrseq_power_off(slot->pwrseq);
return 0;
}
regulator_bulk_disable(slot->num_supplies, slot->supplies);
clk_disable_unprepare(slot->clk);
return 0;
}
static void devm_slot_pwrctrl_release(void *data)
{
struct slot_pwrctrl *slot = data;
regulator_bulk_free(slot->num_supplies, slot->supplies);
}
static int slot_pwrctrl_probe(struct platform_device *pdev)
{
struct slot_pwrctrl *slot;
struct device *dev = &pdev->dev;
int ret;
slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL);
if (!slot)
return -ENOMEM;
if (of_graph_is_present(dev_of_node(dev))) {
slot->pwrseq = devm_pwrseq_get(dev, "pcie");
if (IS_ERR(slot->pwrseq))
return dev_err_probe(dev, PTR_ERR(slot->pwrseq),
"Failed to get the power sequencer\n");
goto skip_resources;
}
ret = of_regulator_bulk_get_all(dev, dev_of_node(dev),
&slot->supplies);
if (ret < 0)
return dev_err_probe(dev, ret, "Failed to get slot regulators\n");
slot->num_supplies = ret;
slot->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(slot->clk))
return dev_err_probe(dev, PTR_ERR(slot->clk),
"Failed to enable slot clock\n");
skip_resources:
slot->pwrctrl.power_on = slot_pwrctrl_power_on;
slot->pwrctrl.power_off = slot_pwrctrl_power_off;
ret = devm_add_action_or_reset(dev, devm_slot_pwrctrl_release, slot);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/of_graph.h`, `linux/pci-pwrctrl.h`, `linux/platform_device.h`, `linux/pwrseq/consumer.h`.
- Detected declarations: `struct slot_pwrctrl`, `function slot_pwrctrl_power_on`, `function slot_pwrctrl_power_off`, `function devm_slot_pwrctrl_release`, `function slot_pwrctrl_probe`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: source 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.