drivers/acpi/ec.c
Source file repositories/reference/linux-study-clean/drivers/acpi/ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/ec.c- Extension
.c- Size
- 62799 bytes
- Lines
- 2379
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/init.hlinux/types.hlinux/delay.hlinux/interrupt.hlinux/list.hlinux/platform_device.hlinux/printk.hlinux/spinlock.hlinux/slab.hlinux/string.hlinux/suspend.hlinux/acpi.hlinux/dmi.hasm/io.hinternal.h
Detected Declarations
struct acpi_ec_query_handlerstruct transactionstruct acpi_ec_queryenum ec_commandfunction acpi_ec_startedfunction acpi_ec_event_enabledfunction acpi_ec_flushedfunction acpi_ec_read_statusfunction acpi_ec_read_datafunction acpi_ec_write_cmdfunction acpi_ec_write_datafunction acpi_ec_gpe_status_setfunction acpi_ec_enable_gpefunction acpi_ec_disable_gpefunction acpi_ec_submit_requestfunction acpi_ec_complete_requestfunction acpi_ec_mask_eventsfunction acpi_ec_unmask_eventsfunction acpi_ec_submit_flushable_requestfunction acpi_ec_submit_eventfunction acpi_ec_complete_eventfunction acpi_ec_close_eventfunction __acpi_ec_enable_eventfunction __acpi_ec_disable_eventfunction acpi_ec_clearfunction acpi_ec_enable_eventfunction __acpi_ec_flush_workfunction acpi_ec_disable_eventfunction acpi_ec_flush_workfunction acpi_ec_guard_eventfunction ec_transaction_polledfunction ec_transaction_completedfunction ec_transaction_transitionfunction acpi_ec_spurious_interruptfunction advance_transactionfunction start_transactionfunction ec_guardfunction ec_pollfunction acpi_ec_transaction_unlockedfunction acpi_ec_transactionfunction acpi_ec_burst_enablefunction acpi_ec_burst_disablefunction acpi_ec_readfunction acpi_ec_read_unlockedfunction acpi_ec_writefunction acpi_ec_write_unlockedfunction ec_readfunction ec_write
Annotated Snippet
struct acpi_ec_query_handler {
struct list_head node;
acpi_ec_query_func func;
acpi_handle handle;
void *data;
u8 query_bit;
struct kref kref;
};
struct transaction {
const u8 *wdata;
u8 *rdata;
unsigned short irq_count;
u8 command;
u8 wi;
u8 ri;
u8 wlen;
u8 rlen;
u8 flags;
};
struct acpi_ec_query {
struct transaction transaction;
struct work_struct work;
struct acpi_ec_query_handler *handler;
struct acpi_ec *ec;
};
static int acpi_ec_submit_query(struct acpi_ec *ec);
static void advance_transaction(struct acpi_ec *ec, bool interrupt);
static void acpi_ec_event_handler(struct work_struct *work);
struct acpi_ec *first_ec;
EXPORT_SYMBOL(first_ec);
static struct acpi_ec *boot_ec;
static bool boot_ec_is_ecdt;
static struct workqueue_struct *ec_wq;
static struct workqueue_struct *ec_query_wq;
static int EC_FLAGS_CORRECT_ECDT; /* Needs ECDT port address correction */
static int EC_FLAGS_TRUST_DSDT_GPE; /* Needs DSDT GPE as correction setting */
static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
/* --------------------------------------------------------------------------
* Logging/Debugging
* -------------------------------------------------------------------------- */
/*
* Splitters used by the developers to track the boundary of the EC
* handling processes.
*/
#ifdef DEBUG
#define EC_DBG_SEP " "
#define EC_DBG_DRV "+++++"
#define EC_DBG_STM "====="
#define EC_DBG_REQ "*****"
#define EC_DBG_EVT "#####"
#else
#define EC_DBG_SEP ""
#define EC_DBG_DRV
#define EC_DBG_STM
#define EC_DBG_REQ
#define EC_DBG_EVT
#endif
#define ec_log_raw(fmt, ...) \
pr_info(fmt "\n", ##__VA_ARGS__)
#define ec_dbg_raw(fmt, ...) \
pr_debug(fmt "\n", ##__VA_ARGS__)
#define ec_log(filter, fmt, ...) \
ec_log_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
#define ec_dbg(filter, fmt, ...) \
ec_dbg_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
#define ec_log_drv(fmt, ...) \
ec_log(EC_DBG_DRV, fmt, ##__VA_ARGS__)
#define ec_dbg_drv(fmt, ...) \
ec_dbg(EC_DBG_DRV, fmt, ##__VA_ARGS__)
#define ec_dbg_stm(fmt, ...) \
ec_dbg(EC_DBG_STM, fmt, ##__VA_ARGS__)
#define ec_dbg_req(fmt, ...) \
ec_dbg(EC_DBG_REQ, fmt, ##__VA_ARGS__)
#define ec_dbg_evt(fmt, ...) \
ec_dbg(EC_DBG_EVT, fmt, ##__VA_ARGS__)
#define ec_dbg_ref(ec, fmt, ...) \
ec_dbg_raw("%lu: " fmt, ec->reference_count, ## __VA_ARGS__)
/* --------------------------------------------------------------------------
* Device Flags
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/list.h`, `linux/platform_device.h`.
- Detected declarations: `struct acpi_ec_query_handler`, `struct transaction`, `struct acpi_ec_query`, `enum ec_command`, `function acpi_ec_started`, `function acpi_ec_event_enabled`, `function acpi_ec_flushed`, `function acpi_ec_read_status`, `function acpi_ec_read_data`, `function acpi_ec_write_cmd`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.