drivers/watchdog/acquirewdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/acquirewdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/acquirewdt.c- Extension
.c- Size
- 8470 bytes
- Lines
- 329
- 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/errno.hlinux/kernel.hlinux/miscdevice.hlinux/watchdog.hlinux/fs.hlinux/ioport.hlinux/platform_device.hlinux/init.hlinux/uaccess.hlinux/io.h
Detected Declarations
function acq_keepalivefunction acq_stopfunction acq_writefunction acq_ioctlfunction acq_openfunction acq_closefunction acq_probefunction acq_removefunction acq_shutdownfunction acq_initfunction acq_exitmodule init acq_init
Annotated Snippet
static const struct file_operations acq_fops = {
.owner = THIS_MODULE,
.write = acq_write,
.unlocked_ioctl = acq_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = acq_open,
.release = acq_close,
};
static struct miscdevice acq_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &acq_fops,
};
/*
* Init & exit routines
*/
static int __init acq_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;
}
ret = misc_register(&acq_miscdev);
if (ret != 0) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
goto unreg_regions;
}
pr_info("initialized. (nowayout=%d)\n", nowayout);
return 0;
unreg_regions:
release_region(wdt_start, 1);
unreg_stop:
if (wdt_stop != wdt_start)
release_region(wdt_stop, 1);
out:
return ret;
}
static void acq_remove(struct platform_device *dev)
{
misc_deregister(&acq_miscdev);
release_region(wdt_start, 1);
if (wdt_stop != wdt_start)
release_region(wdt_stop, 1);
}
static void acq_shutdown(struct platform_device *dev)
{
/* Turn the WDT off if we have a soft shutdown */
acq_stop();
}
static struct platform_driver acquirewdt_driver = {
.remove = acq_remove,
.shutdown = acq_shutdown,
.driver = {
.name = DRV_NAME,
},
};
static int __init acq_init(void)
{
int err;
pr_info("WDT driver for Acquire single board computer initialising\n");
acq_platform_device = platform_device_register_simple(DRV_NAME,
-1, NULL, 0);
if (IS_ERR(acq_platform_device))
return PTR_ERR(acq_platform_device);
err = platform_driver_probe(&acquirewdt_driver, acq_probe);
if (err)
goto unreg_platform_device;
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/fs.h`.
- Detected declarations: `function acq_keepalive`, `function acq_stop`, `function acq_write`, `function acq_ioctl`, `function acq_open`, `function acq_close`, `function acq_probe`, `function acq_remove`, `function acq_shutdown`, `function acq_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.
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.