drivers/power/sequencing/core.c
Source file repositories/reference/linux-study-clean/drivers/power/sequencing/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/sequencing/core.c- Extension
.c- Size
- 27715 bytes
- Lines
- 1131
- Domain
- Driver Families
- Bucket
- drivers/power
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/bug.hlinux/cleanup.hlinux/debugfs.hlinux/device.hlinux/err.hlinux/export.hlinux/idr.hlinux/kernel.hlinux/kref.hlinux/list.hlinux/lockdep.hlinux/module.hlinux/mutex.hlinux/property.hlinux/pwrseq/consumer.hlinux/pwrseq/provider.hlinux/radix-tree.hlinux/rwsem.hlinux/slab.h
Detected Declarations
struct pwrseq_unitstruct pwrseq_unit_depstruct pwrseq_targetstruct pwrseq_devicestruct pwrseq_descstruct pwrseq_match_datastruct pwrseq_debugfs_count_ctxfunction pwrseq_unit_putfunction pwrseq_unit_dep_freefunction pwrseq_unit_free_depsfunction list_for_each_entry_safefunction pwrseq_unit_releasefunction pwrseq_target_newfunction pwrseq_target_freefunction pwrseq_device_putfunction pwrseq_releasefunction list_for_each_entry_safefunction pwrseq_check_unit_depsfunction pwrseq_check_target_depsfunction pwrseq_unit_setupfunction pwrseq_unit_setup_depsfunction pwrseq_do_setup_targetsfunction pwrseq_setup_targetsfunction pwrseq_device_registerfunction scoped_guardfunction pwrseq_device_unregisterfunction scoped_guardfunction devm_pwrseq_device_unregisterfunction devm_pwrseq_device_registerfunction pwrseq_device_get_drvdatafunction pwrseq_match_devicefunction pwrseq_getfunction pwrseq_putfunction devm_pwrseq_putfunction devm_pwrseq_getfunction pwrseq_unit_enable_depsfunction list_for_each_entryfunction pwrseq_unit_disable_depsfunction list_for_each_entry_reversefunction pwrseq_unit_enablefunction pwrseq_unit_disablefunction pwrseq_power_onfunction scoped_guardfunction pwrseq_power_offfunction pwrseq_to_devicefunction pwrseq_debugfs_seq_countfunction pwrseq_debugfs_seq_show_targetfunction pwrseq_debugfs_seq_show_unit
Annotated Snippet
static const struct bus_type pwrseq_bus = {
.name = "pwrseq",
};
static void pwrseq_release(struct device *dev)
{
struct pwrseq_device *pwrseq = to_pwrseq_device(dev);
struct pwrseq_target *target, *pos;
list_for_each_entry_safe(target, pos, &pwrseq->targets, list) {
list_del(&target->list);
pwrseq_target_free(target);
}
mutex_destroy(&pwrseq->state_lock);
ida_free(&pwrseq_ida, pwrseq->id);
kfree(pwrseq);
}
static const struct device_type pwrseq_device_type = {
.name = "power_sequencer",
.release = pwrseq_release,
};
static int pwrseq_check_unit_deps(const struct pwrseq_unit_data *data,
struct radix_tree_root *visited_units)
{
const struct pwrseq_unit_data *tmp, **cur;
int ret;
ret = radix_tree_insert(visited_units, (unsigned long)data,
(void *)data);
if (ret)
return ret;
for (cur = data->deps; cur && *cur; cur++) {
tmp = radix_tree_lookup(visited_units, (unsigned long)*cur);
if (tmp) {
WARN(1, "Circular dependency in power sequencing flow detected!\n");
return -EINVAL;
}
ret = pwrseq_check_unit_deps(*cur, visited_units);
if (ret)
return ret;
}
return 0;
}
static int pwrseq_check_target_deps(const struct pwrseq_target_data *data)
{
struct radix_tree_root visited_units;
struct radix_tree_iter iter;
void __rcu **slot;
int ret;
if (!data->unit)
return -EINVAL;
INIT_RADIX_TREE(&visited_units, GFP_KERNEL);
ret = pwrseq_check_unit_deps(data->unit, &visited_units);
radix_tree_for_each_slot(slot, &visited_units, &iter, 0)
radix_tree_delete(&visited_units, iter.index);
return ret;
}
static int pwrseq_unit_setup_deps(const struct pwrseq_unit_data **data,
struct list_head *dep_list,
struct list_head *unit_list,
struct radix_tree_root *processed_units);
static struct pwrseq_unit *
pwrseq_unit_setup(const struct pwrseq_unit_data *data,
struct list_head *unit_list,
struct radix_tree_root *processed_units)
{
struct pwrseq_unit *unit;
int ret;
unit = radix_tree_lookup(processed_units, (unsigned long)data);
if (unit)
return pwrseq_unit_get(unit);
unit = pwrseq_unit_new(data);
if (!unit)
return ERR_PTR(-ENOMEM);
if (data->deps) {
Annotation
- Immediate include surface: `linux/bug.h`, `linux/cleanup.h`, `linux/debugfs.h`, `linux/device.h`, `linux/err.h`, `linux/export.h`, `linux/idr.h`, `linux/kernel.h`.
- Detected declarations: `struct pwrseq_unit`, `struct pwrseq_unit_dep`, `struct pwrseq_target`, `struct pwrseq_device`, `struct pwrseq_desc`, `struct pwrseq_match_data`, `struct pwrseq_debugfs_count_ctx`, `function pwrseq_unit_put`, `function pwrseq_unit_dep_free`, `function pwrseq_unit_free_deps`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: pattern 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.