drivers/watchdog/rdc321x_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/rdc321x_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/rdc321x_wdt.c- Extension
.c- Size
- 6670 bytes
- Lines
- 282
- 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/moduleparam.hlinux/types.hlinux/errno.hlinux/miscdevice.hlinux/fs.hlinux/ioport.hlinux/timer.hlinux/completion.hlinux/jiffies.hlinux/platform_device.hlinux/watchdog.hlinux/io.hlinux/uaccess.hlinux/mfd/rdc321x.h
Detected Declarations
function rdc321x_wdt_triggerfunction rdc321x_wdt_resetfunction rdc321x_wdt_startfunction rdc321x_wdt_stopfunction rdc321x_wdt_openfunction rdc321x_wdt_releasefunction rdc321x_wdt_ioctlfunction rdc321x_wdt_writefunction rdc321x_wdt_probefunction rdc321x_wdt_remove
Annotated Snippet
static const struct file_operations rdc321x_wdt_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = rdc321x_wdt_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = rdc321x_wdt_open,
.write = rdc321x_wdt_write,
.release = rdc321x_wdt_release,
};
static struct miscdevice rdc321x_wdt_misc = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &rdc321x_wdt_fops,
};
static int rdc321x_wdt_probe(struct platform_device *pdev)
{
int err;
struct resource *r;
struct rdc321x_wdt_pdata *pdata;
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
dev_err(&pdev->dev, "no platform data supplied\n");
return -ENODEV;
}
r = platform_get_resource_byname(pdev, IORESOURCE_IO, "wdt-reg");
if (!r) {
dev_err(&pdev->dev, "failed to get wdt-reg resource\n");
return -ENODEV;
}
rdc321x_wdt_device.sb_pdev = pdata->sb_pdev;
rdc321x_wdt_device.base_reg = r->start;
rdc321x_wdt_device.queue = 0;
rdc321x_wdt_device.default_ticks = ticks;
err = misc_register(&rdc321x_wdt_misc);
if (err < 0) {
dev_err(&pdev->dev, "misc_register failed\n");
return err;
}
spin_lock_init(&rdc321x_wdt_device.lock);
/* Reset the watchdog */
pci_write_config_dword(rdc321x_wdt_device.sb_pdev,
rdc321x_wdt_device.base_reg, RDC_WDT_RST);
init_completion(&rdc321x_wdt_device.stop);
clear_bit(0, &rdc321x_wdt_device.inuse);
timer_setup(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0);
dev_info(&pdev->dev, "watchdog init success\n");
return 0;
}
static void rdc321x_wdt_remove(struct platform_device *pdev)
{
if (rdc321x_wdt_device.queue) {
rdc321x_wdt_device.queue = 0;
wait_for_completion(&rdc321x_wdt_device.stop);
}
misc_deregister(&rdc321x_wdt_misc);
}
static struct platform_driver rdc321x_wdt_driver = {
.probe = rdc321x_wdt_probe,
.remove = rdc321x_wdt_remove,
.driver = {
.name = "rdc321x-wdt",
},
};
module_platform_driver(rdc321x_wdt_driver);
MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
MODULE_DESCRIPTION("RDC321x watchdog driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/errno.h`, `linux/miscdevice.h`, `linux/fs.h`, `linux/ioport.h`, `linux/timer.h`.
- Detected declarations: `function rdc321x_wdt_trigger`, `function rdc321x_wdt_reset`, `function rdc321x_wdt_start`, `function rdc321x_wdt_stop`, `function rdc321x_wdt_open`, `function rdc321x_wdt_release`, `function rdc321x_wdt_ioctl`, `function rdc321x_wdt_write`, `function rdc321x_wdt_probe`, `function rdc321x_wdt_remove`.
- 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.