drivers/watchdog/wdt_pci.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/wdt_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/wdt_pci.c- Extension
.c- Size
- 17437 bytes
- Lines
- 741
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/module.hlinux/moduleparam.hlinux/types.hlinux/miscdevice.hlinux/watchdog.hlinux/ioport.hlinux/delay.hlinux/notifier.hlinux/reboot.hlinux/fs.hlinux/pci.hlinux/io.hlinux/uaccess.hwd501p.h
Detected Declarations
function wdtpci_ctr_modefunction wdtpci_ctr_loadfunction wdtpci_startfunction wdtpci_stopfunction wdtpci_pingfunction wdtpci_set_heartbeatfunction wdtpci_get_statusfunction wdtpci_get_temperaturefunction wdtpci_interruptfunction wdtpci_writefunction wdtpci_ioctlfunction wdtpci_openfunction wdtpci_releasefunction wdtpci_temp_readfunction wdtpci_temp_openfunction wdtpci_temp_releasefunction wdtpci_notify_sysfunction wdtpci_init_onefunction wdtpci_remove_one
Annotated Snippet
static const struct file_operations wdtpci_fops = {
.owner = THIS_MODULE,
.write = wdtpci_write,
.unlocked_ioctl = wdtpci_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = wdtpci_open,
.release = wdtpci_release,
};
static struct miscdevice wdtpci_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &wdtpci_fops,
};
static const struct file_operations wdtpci_temp_fops = {
.owner = THIS_MODULE,
.read = wdtpci_temp_read,
.open = wdtpci_temp_open,
.release = wdtpci_temp_release,
};
static struct miscdevice temp_miscdev = {
.minor = TEMP_MINOR,
.name = "temperature",
.fops = &wdtpci_temp_fops,
};
/*
* The WDT card needs to learn about soft shutdowns in order to
* turn the timebomb registers off.
*/
static struct notifier_block wdtpci_notifier = {
.notifier_call = wdtpci_notify_sys,
};
static int wdtpci_init_one(struct pci_dev *dev,
const struct pci_device_id *ent)
{
int ret = -EIO;
dev_count++;
if (dev_count > 1) {
pr_err("This driver only supports one device\n");
return -ENODEV;
}
if (type != 500 && type != 501) {
pr_err("unknown card type '%d'\n", type);
return -ENODEV;
}
if (pci_enable_device(dev)) {
pr_err("Not possible to enable PCI Device\n");
return -ENODEV;
}
if (pci_resource_start(dev, 2) == 0x0000) {
pr_err("No I/O-Address for card detected\n");
ret = -ENODEV;
goto out_pci;
}
if (pci_request_region(dev, 2, "wdt_pci")) {
pr_err("I/O address 0x%llx already in use\n",
(unsigned long long)pci_resource_start(dev, 2));
goto out_pci;
}
irq = dev->irq;
io = pci_resource_start(dev, 2);
if (request_irq(irq, wdtpci_interrupt, IRQF_SHARED,
"wdt_pci", &wdtpci_miscdev)) {
pr_err("IRQ %d is not free\n", irq);
goto out_reg;
}
pr_info("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%llx (Interrupt %d)\n",
(unsigned long long)io, irq);
/* Check that the heartbeat value is within its range;
if not reset to the default */
if (wdtpci_set_heartbeat(heartbeat)) {
wdtpci_set_heartbeat(WD_TIMO);
pr_info("heartbeat value must be 0 < heartbeat < 65536, using %d\n",
WD_TIMO);
}
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/miscdevice.h`, `linux/watchdog.h`, `linux/ioport.h`, `linux/delay.h`.
- Detected declarations: `function wdtpci_ctr_mode`, `function wdtpci_ctr_load`, `function wdtpci_start`, `function wdtpci_stop`, `function wdtpci_ping`, `function wdtpci_set_heartbeat`, `function wdtpci_get_status`, `function wdtpci_get_temperature`, `function wdtpci_interrupt`, `function wdtpci_write`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.