drivers/watchdog/advantechwdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/advantechwdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/advantechwdt.c- Extension
.c- Size
- 7763 bytes
- Lines
- 338
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/moduleparam.hlinux/types.hlinux/miscdevice.hlinux/watchdog.hlinux/fs.hlinux/ioport.hlinux/platform_device.hlinux/init.hlinux/io.hlinux/uaccess.h
Detected Declarations
function advwdt_pingfunction advwdt_disablefunction advwdt_set_heartbeatfunction advwdt_writefunction advwdt_ioctlfunction advwdt_openfunction advwdt_closefunction advwdt_probefunction advwdt_removefunction advwdt_shutdownfunction advwdt_initfunction advwdt_exitmodule init advwdt_init
Annotated Snippet
static const struct file_operations advwdt_fops = {
.owner = THIS_MODULE,
.write = advwdt_write,
.unlocked_ioctl = advwdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = advwdt_open,
.release = advwdt_close,
};
static struct miscdevice advwdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &advwdt_fops,
};
/*
* Init & exit routines
*/
static int __init advwdt_probe(struct platform_device *dev)
{
int ret;
if (wdt_stop != wdt_start) {
if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n",
wdt_stop);
ret = -EIO;
goto out;
}
}
if (!request_region(wdt_start, 1, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n", wdt_start);
ret = -EIO;
goto unreg_stop;
}
/* Check that the heartbeat value is within it's range ;
* if not reset to the default */
if (advwdt_set_heartbeat(timeout)) {
advwdt_set_heartbeat(WATCHDOG_TIMEOUT);
pr_info("timeout value must be 1<=x<=63, using %d\n", timeout);
}
ret = misc_register(&advwdt_miscdev);
if (ret != 0) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
goto unreg_regions;
}
pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
timeout, nowayout);
out:
return ret;
unreg_regions:
release_region(wdt_start, 1);
unreg_stop:
if (wdt_stop != wdt_start)
release_region(wdt_stop, 1);
goto out;
}
static void advwdt_remove(struct platform_device *dev)
{
misc_deregister(&advwdt_miscdev);
release_region(wdt_start, 1);
if (wdt_stop != wdt_start)
release_region(wdt_stop, 1);
}
static void advwdt_shutdown(struct platform_device *dev)
{
/* Turn the WDT off if we have a soft shutdown */
advwdt_disable();
}
static struct platform_driver advwdt_driver = {
.remove = advwdt_remove,
.shutdown = advwdt_shutdown,
.driver = {
.name = DRV_NAME,
},
};
static int __init advwdt_init(void)
{
int err;
pr_info("WDT driver for Advantech single board computer initialising\n");
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/fs.h`, `linux/ioport.h`, `linux/platform_device.h`.
- Detected declarations: `function advwdt_ping`, `function advwdt_disable`, `function advwdt_set_heartbeat`, `function advwdt_write`, `function advwdt_ioctl`, `function advwdt_open`, `function advwdt_close`, `function advwdt_probe`, `function advwdt_remove`, `function advwdt_shutdown`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.