drivers/watchdog/mei_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/mei_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/mei_wdt.c- Extension
.c- Size
- 14953 bytes
- Lines
- 665
- Domain
- Driver Families
- Bucket
- drivers/watchdog
- 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.
- 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/module.hlinux/slab.hlinux/interrupt.hlinux/debugfs.hlinux/completion.hlinux/watchdog.hlinux/uuid.hlinux/mei_cl_bus.h
Detected Declarations
struct mei_wdtstruct mei_mc_hdrstruct mei_wdt_start_requeststruct mei_wdt_start_responsestruct mei_wdt_stop_requestenum mei_wdt_statefunction mei_wdt_pingfunction mei_wdt_stopfunction mei_wdt_ops_startfunction mei_wdt_ops_stopfunction mei_wdt_ops_pingfunction mei_wdt_ops_set_timeoutfunction __mei_wdt_is_registeredfunction mei_wdt_unregisterfunction mei_wdt_registerfunction mei_wdt_unregister_workfunction mei_wdt_rxfunction mei_wdt_notiffunction mei_dbgfs_read_activationfunction mei_dbgfs_read_statefunction dbgfs_unregisterfunction dbgfs_registerfunction dbgfs_unregisterfunction mei_wdt_remove
Annotated Snippet
static const struct file_operations dbgfs_fops_activation = {
.open = simple_open,
.read = mei_dbgfs_read_activation,
.llseek = generic_file_llseek,
};
static ssize_t mei_dbgfs_read_state(struct file *file, char __user *ubuf,
size_t cnt, loff_t *ppos)
{
struct mei_wdt *wdt = file->private_data;
char buf[32];
ssize_t pos;
pos = scnprintf(buf, sizeof(buf), "state: %s\n",
mei_wdt_state_str(wdt->state));
return simple_read_from_buffer(ubuf, cnt, ppos, buf, pos);
}
static const struct file_operations dbgfs_fops_state = {
.open = simple_open,
.read = mei_dbgfs_read_state,
.llseek = generic_file_llseek,
};
static void dbgfs_unregister(struct mei_wdt *wdt)
{
debugfs_remove_recursive(wdt->dbgfs_dir);
wdt->dbgfs_dir = NULL;
}
static void dbgfs_register(struct mei_wdt *wdt)
{
struct dentry *dir;
dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
wdt->dbgfs_dir = dir;
debugfs_create_file("state", S_IRUSR, dir, wdt, &dbgfs_fops_state);
debugfs_create_file("activation", S_IRUSR, dir, wdt,
&dbgfs_fops_activation);
}
#else
static inline void dbgfs_unregister(struct mei_wdt *wdt) {}
static inline void dbgfs_register(struct mei_wdt *wdt) {}
#endif /* CONFIG_DEBUG_FS */
static int mei_wdt_probe(struct mei_cl_device *cldev,
const struct mei_cl_device_id *id)
{
struct mei_wdt *wdt;
int ret;
wdt = kzalloc_obj(struct mei_wdt);
if (!wdt)
return -ENOMEM;
wdt->timeout = MEI_WDT_DEFAULT_TIMEOUT;
wdt->state = MEI_WDT_PROBE;
wdt->cldev = cldev;
wdt->resp_required = mei_cldev_ver(cldev) > 0x1;
mutex_init(&wdt->reg_lock);
init_completion(&wdt->response);
INIT_WORK(&wdt->unregister, mei_wdt_unregister_work);
mei_cldev_set_drvdata(cldev, wdt);
ret = mei_cldev_enable(cldev);
if (ret < 0) {
dev_err(&cldev->dev, "Could not enable cl device\n");
goto err_out;
}
ret = mei_cldev_register_rx_cb(wdt->cldev, mei_wdt_rx);
if (ret) {
dev_err(&cldev->dev, "Could not reg rx event ret=%d\n", ret);
goto err_disable;
}
ret = mei_cldev_register_notif_cb(wdt->cldev, mei_wdt_notif);
/* on legacy devices notification is not supported
*/
if (ret && ret != -EOPNOTSUPP) {
dev_err(&cldev->dev, "Could not reg notif event ret=%d\n", ret);
goto err_disable;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/debugfs.h`, `linux/completion.h`, `linux/watchdog.h`, `linux/uuid.h`, `linux/mei_cl_bus.h`.
- Detected declarations: `struct mei_wdt`, `struct mei_mc_hdr`, `struct mei_wdt_start_request`, `struct mei_wdt_start_response`, `struct mei_wdt_stop_request`, `enum mei_wdt_state`, `function mei_wdt_ping`, `function mei_wdt_stop`, `function mei_wdt_ops_start`, `function mei_wdt_ops_stop`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: pattern 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.