drivers/platform/chrome/wilco_ec/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/platform/chrome/wilco_ec/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/chrome/wilco_ec/debugfs.c- Extension
.c- Size
- 7475 bytes
- Lines
- 288
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/ctype.hlinux/debugfs.hlinux/fs.hlinux/mod_devicetable.hlinux/module.hlinux/platform_data/wilco-ec.hlinux/platform_device.h
Detected Declarations
struct wilco_ec_debugfsstruct ec_requeststruct ec_responsefunction parse_hex_sentencefunction raw_writefunction raw_readfunction send_ec_cmdfunction h1_gpio_getfunction test_event_setfunction wilco_ec_debugfs_probefunction wilco_ec_debugfs_remove
Annotated Snippet
static const struct file_operations fops_raw = {
.owner = THIS_MODULE,
.read = raw_read,
.write = raw_write,
};
#define CMD_KB_CHROME 0x88
#define SUB_CMD_H1_GPIO 0x0A
#define SUB_CMD_TEST_EVENT 0x0B
struct ec_request {
u8 cmd; /* Always CMD_KB_CHROME */
u8 reserved;
u8 sub_cmd;
} __packed;
struct ec_response {
u8 status; /* 0 if allowed */
u8 val;
} __packed;
static int send_ec_cmd(struct wilco_ec_device *ec, u8 sub_cmd, u8 *out_val)
{
struct ec_request rq;
struct ec_response rs;
struct wilco_ec_message msg;
int ret;
memset(&rq, 0, sizeof(rq));
rq.cmd = CMD_KB_CHROME;
rq.sub_cmd = sub_cmd;
memset(&msg, 0, sizeof(msg));
msg.type = WILCO_EC_MSG_LEGACY;
msg.request_data = &rq;
msg.request_size = sizeof(rq);
msg.response_data = &rs;
msg.response_size = sizeof(rs);
ret = wilco_ec_mailbox(ec, &msg);
if (ret < 0)
return ret;
if (rs.status)
return -EIO;
*out_val = rs.val;
return 0;
}
/**
* h1_gpio_get() - Gets h1 gpio status.
* @arg: The wilco EC device.
* @val: BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL
*/
static int h1_gpio_get(void *arg, u64 *val)
{
int ret;
ret = send_ec_cmd(arg, SUB_CMD_H1_GPIO, (u8 *)val);
if (ret == 0)
*val &= 0xFF;
return ret;
}
DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n");
/**
* test_event_set() - Sends command to EC to cause an EC test event.
* @arg: The wilco EC device.
* @val: unused.
*/
static int test_event_set(void *arg, u64 val)
{
u8 ret;
return send_ec_cmd(arg, SUB_CMD_TEST_EVENT, &ret);
}
/* Format is unused since it is only required for get method which is NULL */
DEFINE_DEBUGFS_ATTRIBUTE(fops_test_event, NULL, test_event_set, "%llu\n");
/**
* wilco_ec_debugfs_probe() - Create the debugfs node
* @pdev: The platform device, probably created in core.c
*
* Try to create a debugfs node. If it fails, then we don't want to change
* behavior at all, this is for debugging after all. Just fail silently.
*
* Return: 0 always.
*/
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/debugfs.h`, `linux/fs.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_data/wilco-ec.h`, `linux/platform_device.h`.
- Detected declarations: `struct wilco_ec_debugfs`, `struct ec_request`, `struct ec_response`, `function parse_hex_sentence`, `function raw_write`, `function raw_read`, `function send_ec_cmd`, `function h1_gpio_get`, `function test_event_set`, `function wilco_ec_debugfs_probe`.
- Atlas domain: Driver Families / drivers/platform.
- 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.