drivers/watchdog/ib700wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/ib700wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/ib700wdt.c- Extension
.c- Size
- 8300 bytes
- Lines
- 378
- 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/fs.hlinux/init.hlinux/spinlock.hlinux/moduleparam.hlinux/platform_device.hlinux/io.hlinux/uaccess.h
Detected Declarations
function ibwdt_pingfunction ibwdt_disablefunction ibwdt_set_heartbeatfunction ibwdt_writefunction ibwdt_ioctlfunction ibwdt_openfunction ibwdt_closefunction ibwdt_probefunction ibwdt_removefunction ibwdt_shutdownfunction ibwdt_initfunction ibwdt_exitmodule init ibwdt_init
Annotated Snippet
static const struct file_operations ibwdt_fops = {
.owner = THIS_MODULE,
.write = ibwdt_write,
.unlocked_ioctl = ibwdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = ibwdt_open,
.release = ibwdt_close,
};
static struct miscdevice ibwdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &ibwdt_fops,
};
/*
* Init & exit routines
*/
static int __init ibwdt_probe(struct platform_device *dev)
{
int res;
#if WDT_START != WDT_STOP
if (!request_region(WDT_STOP, 1, "IB700 WDT")) {
pr_err("STOP method I/O %X is not available\n", WDT_STOP);
res = -EIO;
goto out_nostopreg;
}
#endif
if (!request_region(WDT_START, 1, "IB700 WDT")) {
pr_err("START method I/O %X is not available\n", WDT_START);
res = -EIO;
goto out_nostartreg;
}
/* Check that the heartbeat value is within it's range ;
* if not reset to the default */
if (ibwdt_set_heartbeat(timeout)) {
ibwdt_set_heartbeat(WATCHDOG_TIMEOUT);
pr_info("timeout value must be 0<=x<=30, using %d\n", timeout);
}
res = misc_register(&ibwdt_miscdev);
if (res) {
pr_err("failed to register misc device\n");
goto out_nomisc;
}
return 0;
out_nomisc:
release_region(WDT_START, 1);
out_nostartreg:
#if WDT_START != WDT_STOP
release_region(WDT_STOP, 1);
#endif
out_nostopreg:
return res;
}
static void ibwdt_remove(struct platform_device *dev)
{
misc_deregister(&ibwdt_miscdev);
release_region(WDT_START, 1);
#if WDT_START != WDT_STOP
release_region(WDT_STOP, 1);
#endif
}
static void ibwdt_shutdown(struct platform_device *dev)
{
/* Turn the WDT off if we have a soft shutdown */
ibwdt_disable();
}
static struct platform_driver ibwdt_driver = {
.remove = ibwdt_remove,
.shutdown = ibwdt_shutdown,
.driver = {
.name = DRV_NAME,
},
};
static int __init ibwdt_init(void)
{
int err;
pr_info("WDT driver for IB700 single board computer initialising\n");
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/ioport.h`, `linux/fs.h`, `linux/init.h`, `linux/spinlock.h`.
- Detected declarations: `function ibwdt_ping`, `function ibwdt_disable`, `function ibwdt_set_heartbeat`, `function ibwdt_write`, `function ibwdt_ioctl`, `function ibwdt_open`, `function ibwdt_close`, `function ibwdt_probe`, `function ibwdt_remove`, `function ibwdt_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.
- 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.