drivers/watchdog/gef_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/gef_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/gef_wdt.c- Extension
.c- Size
- 7451 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.
- 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/kernel.hlinux/compiler.hlinux/init.hlinux/module.hlinux/miscdevice.hlinux/watchdog.hlinux/fs.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/io.hlinux/uaccess.hsysdev/fsl_soc.h
Detected Declarations
function gef_wdt_toggle_wdcfunction gef_wdt_servicefunction gef_wdt_handler_enablefunction gef_wdt_handler_disablefunction gef_wdt_set_timeoutfunction gef_wdt_writefunction gef_wdt_ioctlfunction gef_wdt_openfunction gef_wdt_releasefunction gef_wdt_probefunction gef_wdt_removefunction gef_wdt_initfunction gef_wdt_exitmodule init gef_wdt_init
Annotated Snippet
static const struct file_operations gef_wdt_fops = {
.owner = THIS_MODULE,
.write = gef_wdt_write,
.unlocked_ioctl = gef_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = gef_wdt_open,
.release = gef_wdt_release,
};
static struct miscdevice gef_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &gef_wdt_fops,
};
static int gef_wdt_probe(struct platform_device *dev)
{
int timeout = 10;
u32 freq;
bus_clk = 133; /* in MHz */
freq = fsl_get_sys_freq();
if (freq != -1)
bus_clk = freq;
/* Map devices registers into memory */
gef_wdt_regs = of_iomap(dev->dev.of_node, 0);
if (gef_wdt_regs == NULL)
return -ENOMEM;
gef_wdt_set_timeout(timeout);
gef_wdt_handler_disable(); /* in case timer was already running */
return misc_register(&gef_wdt_miscdev);
}
static void gef_wdt_remove(struct platform_device *dev)
{
misc_deregister(&gef_wdt_miscdev);
gef_wdt_handler_disable();
iounmap(gef_wdt_regs);
}
static const struct of_device_id gef_wdt_ids[] = {
{
.compatible = "gef,fpga-wdt",
},
{},
};
MODULE_DEVICE_TABLE(of, gef_wdt_ids);
static struct platform_driver gef_wdt_driver = {
.driver = {
.name = "gef_wdt",
.of_match_table = gef_wdt_ids,
},
.probe = gef_wdt_probe,
.remove = gef_wdt_remove,
};
static int __init gef_wdt_init(void)
{
pr_info("GE watchdog driver\n");
return platform_driver_register(&gef_wdt_driver);
}
static void __exit gef_wdt_exit(void)
{
platform_driver_unregister(&gef_wdt_driver);
}
module_init(gef_wdt_init);
module_exit(gef_wdt_exit);
MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>");
MODULE_DESCRIPTION("GE watchdog driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:gef_wdt");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/compiler.h`, `linux/init.h`, `linux/module.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/fs.h`, `linux/of.h`.
- Detected declarations: `function gef_wdt_toggle_wdc`, `function gef_wdt_service`, `function gef_wdt_handler_enable`, `function gef_wdt_handler_disable`, `function gef_wdt_set_timeout`, `function gef_wdt_write`, `function gef_wdt_ioctl`, `function gef_wdt_open`, `function gef_wdt_release`, `function gef_wdt_probe`.
- 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.