drivers/watchdog/geodewdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/geodewdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/geodewdt.c- Extension
.c- Size
- 6368 bytes
- Lines
- 289
- 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/miscdevice.hlinux/watchdog.hlinux/fs.hlinux/platform_device.hlinux/reboot.hlinux/uaccess.hlinux/cs5535.h
Detected Declarations
function geodewdt_pingfunction geodewdt_disablefunction geodewdt_set_heartbeatfunction geodewdt_openfunction geodewdt_releasefunction geodewdt_writefunction geodewdt_ioctlfunction geodewdt_probefunction geodewdt_removefunction geodewdt_shutdownfunction geodewdt_initfunction geodewdt_exitmodule init geodewdt_init
Annotated Snippet
static const struct file_operations geodewdt_fops = {
.owner = THIS_MODULE,
.write = geodewdt_write,
.unlocked_ioctl = geodewdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = geodewdt_open,
.release = geodewdt_release,
};
static struct miscdevice geodewdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &geodewdt_fops,
};
static int __init geodewdt_probe(struct platform_device *dev)
{
int ret;
wdt_timer = cs5535_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
if (!wdt_timer) {
pr_err("No timers were available\n");
return -ENODEV;
}
/* Set up the timer */
cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP,
GEODEWDT_SCALE | (3 << 8));
/* Set up comparator 2 to reset when the event fires */
cs5535_mfgpt_toggle_event(wdt_timer, MFGPT_CMP2, MFGPT_EVENT_RESET, 1);
/* Set up the initial timeout */
cs5535_mfgpt_write(wdt_timer, MFGPT_REG_CMP2,
timeout * GEODEWDT_HZ);
ret = misc_register(&geodewdt_miscdev);
return ret;
}
static void geodewdt_remove(struct platform_device *dev)
{
misc_deregister(&geodewdt_miscdev);
}
static void geodewdt_shutdown(struct platform_device *dev)
{
geodewdt_disable();
}
static struct platform_driver geodewdt_driver = {
.remove = geodewdt_remove,
.shutdown = geodewdt_shutdown,
.driver = {
.name = DRV_NAME,
},
};
static int __init geodewdt_init(void)
{
int ret;
geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
-1, NULL, 0);
if (IS_ERR(geodewdt_platform_device))
return PTR_ERR(geodewdt_platform_device);
ret = platform_driver_probe(&geodewdt_driver, geodewdt_probe);
if (ret)
goto err;
return 0;
err:
platform_device_unregister(geodewdt_platform_device);
return ret;
}
static void __exit geodewdt_exit(void)
{
platform_device_unregister(geodewdt_platform_device);
platform_driver_unregister(&geodewdt_driver);
}
module_init(geodewdt_init);
module_exit(geodewdt_exit);
MODULE_AUTHOR("Advanced Micro Devices, Inc");
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/fs.h`, `linux/platform_device.h`, `linux/reboot.h`.
- Detected declarations: `function geodewdt_ping`, `function geodewdt_disable`, `function geodewdt_set_heartbeat`, `function geodewdt_open`, `function geodewdt_release`, `function geodewdt_write`, `function geodewdt_ioctl`, `function geodewdt_probe`, `function geodewdt_remove`, `function geodewdt_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.
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.