drivers/watchdog/alim1535_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/alim1535_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/alim1535_wdt.c- Extension
.c- Size
- 9935 bytes
- Lines
- 451
- 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/miscdevice.hlinux/watchdog.hlinux/ioport.hlinux/notifier.hlinux/reboot.hlinux/init.hlinux/fs.hlinux/pci.hlinux/uaccess.hlinux/io.h
Detected Declarations
function ali_startfunction ali_stopfunction timerfunction ali_settimerfunction ali_writefunction ali_ioctlfunction ali_openfunction ali_releasefunction ali_notify_sysfunction ali_find_watchdogfunction watchdog_initfunction watchdog_exitmodule init watchdog_init
Annotated Snippet
static const struct file_operations ali_fops = {
.owner = THIS_MODULE,
.write = ali_write,
.unlocked_ioctl = ali_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = ali_open,
.release = ali_release,
};
static struct miscdevice ali_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &ali_fops,
};
static struct notifier_block ali_notifier = {
.notifier_call = ali_notify_sys,
};
/*
* watchdog_init - module initialiser
*
* Scan for a suitable watchdog and if so initialize it. Return an error
* if we cannot, the error causes the module to unload
*/
static int __init watchdog_init(void)
{
int ret;
/* Check whether or not the hardware watchdog is there */
if (ali_find_watchdog() != 0)
return -ENODEV;
/* Check that the timeout value is within it's range;
if not reset to the default */
if (timeout < 1 || timeout >= 18000) {
timeout = WATCHDOG_TIMEOUT;
pr_info("timeout value must be 0 < timeout < 18000, using %d\n",
timeout);
}
/* Calculate the watchdog's timeout */
ali_settimer(timeout);
ret = register_reboot_notifier(&ali_notifier);
if (ret != 0) {
pr_err("cannot register reboot notifier (err=%d)\n", ret);
goto out;
}
ret = misc_register(&ali_miscdev);
if (ret != 0) {
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
WATCHDOG_MINOR, ret);
goto unreg_reboot;
}
pr_info("initialized. timeout=%d sec (nowayout=%d)\n",
timeout, nowayout);
out:
return ret;
unreg_reboot:
unregister_reboot_notifier(&ali_notifier);
goto out;
}
/*
* watchdog_exit - module de-initialiser
*
* Called while unloading a successfully installed watchdog module.
*/
static void __exit watchdog_exit(void)
{
/* Stop the timer before we leave */
ali_stop();
/* Deregister */
misc_deregister(&ali_miscdev);
unregister_reboot_notifier(&ali_notifier);
pci_dev_put(ali_pci);
}
module_init(watchdog_init);
module_exit(watchdog_exit);
MODULE_AUTHOR("Alan Cox");
MODULE_DESCRIPTION("ALi M1535 PMU Watchdog Timer driver");
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/ioport.h`, `linux/notifier.h`, `linux/reboot.h`.
- Detected declarations: `function ali_start`, `function ali_stop`, `function timer`, `function ali_settimer`, `function ali_write`, `function ali_ioctl`, `function ali_open`, `function ali_release`, `function ali_notify_sys`, `function ali_find_watchdog`.
- 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.