drivers/cpuidle/dt_idle_genpd.c
Source file repositories/reference/linux-study-clean/drivers/cpuidle/dt_idle_genpd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpuidle/dt_idle_genpd.c- Extension
.c- Size
- 4068 bytes
- Lines
- 197
- Domain
- Driver Families
- Bucket
- drivers/cpuidle
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/cpu.hlinux/device.hlinux/kernel.hlinux/pm_domain.hlinux/pm_runtime.hlinux/slab.hlinux/string.hdt_idle_genpd.h
Detected Declarations
function Copyrightfunction pd_parse_statesfunction pd_free_statesfunction dt_idle_pd_freefunction intfunction dt_idle_pd_init_topologyfunction for_each_child_of_node_scopedfunction dt_idle_pd_remove_topologyfunction for_each_child_of_node_scopedfunction dt_idle_detach_cpu
Annotated Snippet
if (!state_buf) {
ret = -ENOMEM;
goto free_state;
}
*state_buf = state;
states[i].data = state_buf;
}
return 0;
free_state:
i--;
for (; i >= 0; i--)
kfree(states[i].data);
return ret;
}
static int pd_parse_states(struct device_node *np,
int (*parse_state)(struct device_node *, u32 *),
struct genpd_power_state **states,
int *state_count)
{
int ret;
/* Parse the domain idle states. */
ret = of_genpd_parse_idle_states(np, states, state_count);
if (ret)
return ret;
/* Fill out the dt specifics for each found state. */
ret = pd_parse_state_nodes(parse_state, *states, *state_count);
if (ret)
kfree(*states);
return ret;
}
static void pd_free_states(struct genpd_power_state *states,
unsigned int state_count)
{
int i;
for (i = 0; i < state_count; i++)
kfree(states[i].data);
kfree(states);
}
void dt_idle_pd_free(struct generic_pm_domain *pd)
{
pd_free_states(pd->states, pd->state_count);
kfree(pd->name);
kfree(pd);
}
struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
int (*parse_state)(struct device_node *, u32 *))
{
struct generic_pm_domain *pd;
struct genpd_power_state *states = NULL;
int ret, state_count = 0;
pd = kzalloc_obj(*pd);
if (!pd)
goto out;
pd->name = kasprintf(GFP_KERNEL, "%pOF", np);
if (!pd->name)
goto free_pd;
/*
* Parse the domain idle states and let genpd manage the state selection
* for those being compatible with "domain-idle-state".
*/
ret = pd_parse_states(np, parse_state, &states, &state_count);
if (ret)
goto free_name;
pd->free_states = pd_free_states;
pd->name = kbasename(pd->name);
pd->states = states;
pd->state_count = state_count;
pr_debug("alloc PM domain %s\n", pd->name);
return pd;
free_name:
kfree(pd->name);
free_pd:
kfree(pd);
out:
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/device.h`, `linux/kernel.h`, `linux/pm_domain.h`, `linux/pm_runtime.h`, `linux/slab.h`, `linux/string.h`, `dt_idle_genpd.h`.
- Detected declarations: `function Copyright`, `function pd_parse_states`, `function pd_free_states`, `function dt_idle_pd_free`, `function int`, `function dt_idle_pd_init_topology`, `function for_each_child_of_node_scoped`, `function dt_idle_pd_remove_topology`, `function for_each_child_of_node_scoped`, `function dt_idle_detach_cpu`.
- Atlas domain: Driver Families / drivers/cpuidle.
- 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.