drivers/acpi/power.c
Source file repositories/reference/linux-study-clean/drivers/acpi/power.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/power.c- Extension
.c- Size
- 30001 bytes
- Lines
- 1161
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/delay.hlinux/dmi.hlinux/kernel.hlinux/module.hlinux/init.hlinux/types.hlinux/slab.hlinux/string_choices.hlinux/pm_runtime.hlinux/sysfs.hlinux/acpi.hsleep.hinternal.h
Detected Declarations
struct acpi_power_dependent_devicestruct acpi_power_resourcestruct acpi_power_resource_entryfunction acpi_power_resources_list_addfunction list_for_each_entryfunction acpi_power_resources_list_freefunction list_for_each_entry_safefunction acpi_power_resource_is_dupfunction acpi_extract_power_resourcesfunction __get_statefunction acpi_power_get_statefunction acpi_power_get_list_statefunction acpi_power_resource_add_dependentfunction acpi_power_resource_remove_dependentfunction acpi_device_power_add_dependentfunction acpi_device_power_add_dependentfunction __acpi_power_onfunction list_for_each_entryfunction acpi_power_on_unlockedfunction acpi_power_onfunction __acpi_power_offfunction acpi_power_off_unlockedfunction acpi_power_offfunction acpi_power_off_listfunction list_for_each_entry_reversefunction acpi_power_on_listfunction list_for_each_entryfunction acpi_power_hide_listfunction list_for_each_entry_reversefunction acpi_power_expose_listfunction list_for_each_entryfunction acpi_power_expose_hidefunction acpi_power_add_remove_devicefunction acpi_power_wakeup_list_initfunction list_for_each_entryfunction _DSWfunction acpi_enable_wakeup_device_powerfunction acpi_disable_wakeup_device_powerfunction acpi_power_get_inferred_statefunction acpi_power_on_resourcesfunction acpi_power_transitionfunction acpi_release_power_resourcefunction resource_in_use_showfunction acpi_power_sysfs_removefunction acpi_power_add_resource_to_listfunction list_for_each_entryfunction resource_is_gp12pxpfunction acpi_resume_on_eb_gp12pxp
Annotated Snippet
struct acpi_power_dependent_device {
struct device *dev;
struct list_head node;
};
struct acpi_power_resource {
struct acpi_device device;
struct list_head list_node;
u32 system_level;
u32 order;
unsigned int ref_count;
u8 state;
struct mutex resource_lock;
struct list_head dependents;
};
struct acpi_power_resource_entry {
struct list_head node;
struct acpi_power_resource *resource;
};
static bool hp_eb_gp12pxp_quirk;
static bool unused_power_resources_quirk;
static LIST_HEAD(acpi_power_resource_list);
static DEFINE_MUTEX(power_resource_list_lock);
/* --------------------------------------------------------------------------
Power Resource Management
-------------------------------------------------------------------------- */
static inline const char *resource_dev_name(struct acpi_power_resource *pr)
{
return dev_name(&pr->device.dev);
}
static inline
struct acpi_power_resource *to_power_resource(struct acpi_device *device)
{
return container_of(device, struct acpi_power_resource, device);
}
static struct acpi_power_resource *acpi_power_get_context(acpi_handle handle)
{
struct acpi_device *device = acpi_fetch_acpi_dev(handle);
if (!device)
return NULL;
return to_power_resource(device);
}
static int acpi_power_resources_list_add(acpi_handle handle,
struct list_head *list)
{
struct acpi_power_resource *resource = acpi_power_get_context(handle);
struct acpi_power_resource_entry *entry;
if (!resource || !list)
return -EINVAL;
entry = kzalloc_obj(*entry);
if (!entry)
return -ENOMEM;
entry->resource = resource;
if (!list_empty(list)) {
struct acpi_power_resource_entry *e;
list_for_each_entry(e, list, node)
if (e->resource->order > resource->order) {
list_add_tail(&entry->node, &e->node);
return 0;
}
}
list_add_tail(&entry->node, list);
return 0;
}
void acpi_power_resources_list_free(struct list_head *list)
{
struct acpi_power_resource_entry *entry, *e;
list_for_each_entry_safe(entry, e, list, node) {
list_del(&entry->node);
kfree(entry);
}
}
static bool acpi_power_resource_is_dup(union acpi_object *package,
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dmi.h`, `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/slab.h`, `linux/string_choices.h`.
- Detected declarations: `struct acpi_power_dependent_device`, `struct acpi_power_resource`, `struct acpi_power_resource_entry`, `function acpi_power_resources_list_add`, `function list_for_each_entry`, `function acpi_power_resources_list_free`, `function list_for_each_entry_safe`, `function acpi_power_resource_is_dup`, `function acpi_extract_power_resources`, `function __get_state`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.