drivers/watchdog/scx200_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/scx200_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/scx200_wdt.c- Extension
.c- Size
- 6293 bytes
- Lines
- 263
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/moduleparam.hlinux/init.hlinux/miscdevice.hlinux/watchdog.hlinux/notifier.hlinux/reboot.hlinux/fs.hlinux/ioport.hlinux/scx200.hlinux/uaccess.hlinux/io.h
Detected Declarations
function scx200_wdt_pingfunction scx200_wdt_update_marginfunction scx200_wdt_enablefunction scx200_wdt_disablefunction scx200_wdt_openfunction scx200_wdt_releasefunction scx200_wdt_notify_sysfunction scx200_wdt_writefunction scx200_wdt_ioctlfunction scx200_wdt_initfunction scx200_wdt_cleanupmodule init scx200_wdt_init
Annotated Snippet
static const struct file_operations scx200_wdt_fops = {
.owner = THIS_MODULE,
.write = scx200_wdt_write,
.unlocked_ioctl = scx200_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = scx200_wdt_open,
.release = scx200_wdt_release,
};
static struct miscdevice scx200_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &scx200_wdt_fops,
};
static int __init scx200_wdt_init(void)
{
int r;
pr_debug("NatSemi SCx200 Watchdog Driver\n");
/* check that we have found the configuration block */
if (!scx200_cb_present())
return -ENODEV;
if (!request_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE,
"NatSemi SCx200 Watchdog")) {
pr_warn("watchdog I/O region busy\n");
return -EBUSY;
}
scx200_wdt_update_margin();
scx200_wdt_disable();
r = register_reboot_notifier(&scx200_wdt_notifier);
if (r) {
pr_err("unable to register reboot notifier\n");
release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE);
return r;
}
r = misc_register(&scx200_wdt_miscdev);
if (r) {
unregister_reboot_notifier(&scx200_wdt_notifier);
release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE);
return r;
}
return 0;
}
static void __exit scx200_wdt_cleanup(void)
{
misc_deregister(&scx200_wdt_miscdev);
unregister_reboot_notifier(&scx200_wdt_notifier);
release_region(scx200_cb_base + SCx200_WDT_OFFSET,
SCx200_WDT_SIZE);
}
module_init(scx200_wdt_init);
module_exit(scx200_wdt_cleanup);
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/notifier.h`, `linux/reboot.h`, `linux/fs.h`.
- Detected declarations: `function scx200_wdt_ping`, `function scx200_wdt_update_margin`, `function scx200_wdt_enable`, `function scx200_wdt_disable`, `function scx200_wdt_open`, `function scx200_wdt_release`, `function scx200_wdt_notify_sys`, `function scx200_wdt_write`, `function scx200_wdt_ioctl`, `function scx200_wdt_init`.
- 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.
- 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.