drivers/watchdog/sbc_fitpc2_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/sbc_fitpc2_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/sbc_fitpc2_wdt.c- Extension
.c- Size
- 5273 bytes
- Lines
- 264
- 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/types.hlinux/miscdevice.hlinux/watchdog.hlinux/ioport.hlinux/delay.hlinux/fs.hlinux/init.hlinux/moduleparam.hlinux/dmi.hlinux/io.hlinux/uaccess.h
Detected Declarations
function wdt_send_datafunction wdt_enablefunction wdt_disablefunction fitpc2_wdt_openfunction fitpc2_wdt_writefunction fitpc2_wdt_ioctlfunction fitpc2_wdt_releasefunction fitpc2_wdt_initfunction fitpc2_wdt_exitmodule init fitpc2_wdt_init
Annotated Snippet
static const struct file_operations fitpc2_wdt_fops = {
.owner = THIS_MODULE,
.write = fitpc2_wdt_write,
.unlocked_ioctl = fitpc2_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = fitpc2_wdt_open,
.release = fitpc2_wdt_release,
};
static struct miscdevice fitpc2_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &fitpc2_wdt_fops,
};
static int __init fitpc2_wdt_init(void)
{
int err;
const char *brd_name;
brd_name = dmi_get_system_info(DMI_BOARD_NAME);
if (!brd_name || !strstr(brd_name, "SBC-FITPC2"))
return -ENODEV;
pr_info("%s found\n", brd_name);
if (!request_region(COMMAND_PORT, 1, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n", COMMAND_PORT);
return -EIO;
}
if (!request_region(DATA_PORT, 1, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n", DATA_PORT);
err = -EIO;
goto err_data_port;
}
if (margin < 31 || margin > 255) {
pr_err("margin must be in range 31 - 255 seconds, you tried to set %d\n",
margin);
err = -EINVAL;
goto err_margin;
}
err = misc_register(&fitpc2_wdt_miscdev);
if (err) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, err);
goto err_margin;
}
return 0;
err_margin:
release_region(DATA_PORT, 1);
err_data_port:
release_region(COMMAND_PORT, 1);
return err;
}
static void __exit fitpc2_wdt_exit(void)
{
misc_deregister(&fitpc2_wdt_miscdev);
release_region(DATA_PORT, 1);
release_region(COMMAND_PORT, 1);
}
module_init(fitpc2_wdt_init);
module_exit(fitpc2_wdt_exit);
MODULE_AUTHOR("Denis Turischev <denis@compulab.co.il>");
MODULE_DESCRIPTION("SBC-FITPC2 Watchdog");
module_param(margin, int, 0);
MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)");
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/ioport.h`, `linux/delay.h`, `linux/fs.h`, `linux/init.h`.
- Detected declarations: `function wdt_send_data`, `function wdt_enable`, `function wdt_disable`, `function fitpc2_wdt_open`, `function fitpc2_wdt_write`, `function fitpc2_wdt_ioctl`, `function fitpc2_wdt_release`, `function fitpc2_wdt_init`, `function fitpc2_wdt_exit`, `module init fitpc2_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.