drivers/watchdog/at91rm9200_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/at91rm9200_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/at91rm9200_wdt.c- Extension
.c- Size
- 7754 bytes
- Lines
- 333
- 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/bitops.hlinux/delay.hlinux/errno.hlinux/fs.hlinux/init.hlinux/io.hlinux/kernel.hlinux/mfd/syscon.hlinux/mfd/syscon/atmel-st.hlinux/miscdevice.hlinux/mod_devicetable.hlinux/module.hlinux/moduleparam.hlinux/platform_device.hlinux/reboot.hlinux/regmap.hlinux/types.hlinux/watchdog.hlinux/uaccess.h
Detected Declarations
function at91rm9200_restartfunction at91_wdt_stopfunction at91_wdt_startfunction at91_wdt_reloadfunction at91_wdt_openfunction at91_wdt_closefunction at91_wdt_settimeoutfunction at91_wdt_ioctlfunction at91_wdt_writefunction at91wdt_probefunction at91wdt_removefunction at91wdt_shutdownfunction at91wdt_suspendfunction at91wdt_resumefunction at91_wdt_initfunction at91_wdt_exitmodule init at91_wdt_init
Annotated Snippet
static const struct file_operations at91wdt_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = at91_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = at91_wdt_open,
.release = at91_wdt_close,
.write = at91_wdt_write,
};
static struct miscdevice at91wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &at91wdt_fops,
};
static int at91wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device *parent;
int res;
if (at91wdt_miscdev.parent)
return -EBUSY;
at91wdt_miscdev.parent = &pdev->dev;
parent = dev->parent;
if (!parent) {
dev_err(dev, "no parent\n");
return -ENODEV;
}
regmap_st = syscon_node_to_regmap(parent->of_node);
if (IS_ERR(regmap_st))
return -ENODEV;
res = misc_register(&at91wdt_miscdev);
if (res)
return res;
res = register_restart_handler(&at91rm9200_restart_nb);
if (res)
dev_warn(dev, "failed to register restart handler\n");
pr_info("AT91 Watchdog Timer enabled (%d seconds%s)\n",
wdt_time, nowayout ? ", nowayout" : "");
return 0;
}
static void at91wdt_remove(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
int res;
res = unregister_restart_handler(&at91rm9200_restart_nb);
if (res)
dev_warn(dev, "failed to unregister restart handler\n");
misc_deregister(&at91wdt_miscdev);
at91wdt_miscdev.parent = NULL;
}
static void at91wdt_shutdown(struct platform_device *pdev)
{
at91_wdt_stop();
}
static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
{
at91_wdt_stop();
return 0;
}
static int at91wdt_resume(struct platform_device *pdev)
{
if (at91wdt_busy)
at91_wdt_start();
return 0;
}
static const struct of_device_id at91_wdt_dt_ids[] = {
{ .compatible = "atmel,at91rm9200-wdt" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, at91_wdt_dt_ids);
static struct platform_driver at91wdt_driver = {
.probe = at91wdt_probe,
.remove = at91wdt_remove,
.shutdown = at91wdt_shutdown,
.suspend = pm_ptr(at91wdt_suspend),
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/errno.h`, `linux/fs.h`, `linux/init.h`, `linux/io.h`, `linux/kernel.h`, `linux/mfd/syscon.h`.
- Detected declarations: `function at91rm9200_restart`, `function at91_wdt_stop`, `function at91_wdt_start`, `function at91_wdt_reload`, `function at91_wdt_open`, `function at91_wdt_close`, `function at91_wdt_settimeout`, `function at91_wdt_ioctl`, `function at91_wdt_write`, `function at91wdt_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.
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.