drivers/watchdog/pcwd_pci.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/pcwd_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/pcwd_pci.c- Extension
.c- Size
- 20143 bytes
- Lines
- 818
- 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/kernel.hlinux/delay.hlinux/miscdevice.hlinux/watchdog.hlinux/notifier.hlinux/reboot.hlinux/init.hlinux/fs.hlinux/pci.hlinux/ioport.hlinux/spinlock.hlinux/uaccess.hlinux/io.h
Detected Declarations
function send_commandfunction pcipcwd_check_temperature_supportfunction pcipcwd_get_option_switchesfunction pcipcwd_show_card_infofunction pcipcwd_startfunction pcipcwd_stopfunction pcipcwd_keepalivefunction pcipcwd_set_heartbeatfunction pcipcwd_get_statusfunction pcipcwd_clear_statusfunction pcipcwd_get_temperaturefunction pcipcwd_get_timeleftfunction pcipcwd_writefunction pcipcwd_ioctlfunction pcipcwd_openfunction pcipcwd_releasefunction pcipcwd_temp_readfunction pcipcwd_temp_openfunction pcipcwd_temp_releasefunction pcipcwd_notify_sysfunction pcipcwd_card_initfunction pcipcwd_card_exit
Annotated Snippet
static const struct file_operations pcipcwd_fops = {
.owner = THIS_MODULE,
.write = pcipcwd_write,
.unlocked_ioctl = pcipcwd_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.open = pcipcwd_open,
.release = pcipcwd_release,
};
static struct miscdevice pcipcwd_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
.fops = &pcipcwd_fops,
};
static const struct file_operations pcipcwd_temp_fops = {
.owner = THIS_MODULE,
.read = pcipcwd_temp_read,
.open = pcipcwd_temp_open,
.release = pcipcwd_temp_release,
};
static struct miscdevice pcipcwd_temp_miscdev = {
.minor = TEMP_MINOR,
.name = "temperature",
.fops = &pcipcwd_temp_fops,
};
static struct notifier_block pcipcwd_notifier = {
.notifier_call = pcipcwd_notify_sys,
};
/*
* Init & exit routines
*/
static int pcipcwd_card_init(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
int ret = -EIO;
cards_found++;
if (cards_found == 1)
pr_info("%s\n", DRIVER_VERSION);
if (cards_found > 1) {
pr_err("This driver only supports 1 device\n");
return -ENODEV;
}
if (pci_enable_device(pdev)) {
pr_err("Not possible to enable PCI Device\n");
return -ENODEV;
}
if (pci_resource_start(pdev, 0) == 0x0000) {
pr_err("No I/O-Address for card detected\n");
ret = -ENODEV;
goto err_out_disable_device;
}
spin_lock_init(&pcipcwd_private.io_lock);
pcipcwd_private.pdev = pdev;
pcipcwd_private.io_addr = pci_resource_start(pdev, 0);
if (pci_request_regions(pdev, WATCHDOG_NAME)) {
pr_err("I/O address 0x%04x already in use\n",
(int) pcipcwd_private.io_addr);
ret = -EIO;
goto err_out_disable_device;
}
/* get the boot_status */
pcipcwd_get_status(&pcipcwd_private.boot_status);
/* clear the "card caused reboot" flag */
pcipcwd_clear_status();
/* disable card */
pcipcwd_stop();
/* Check whether or not the card supports the temperature device */
pcipcwd_check_temperature_support();
/* Show info about the card itself */
pcipcwd_show_card_info();
/* If heartbeat = 0 then we use the heartbeat from the dip-switches */
if (heartbeat == 0)
heartbeat =
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/delay.h`, `linux/miscdevice.h`, `linux/watchdog.h`.
- Detected declarations: `function send_command`, `function pcipcwd_check_temperature_support`, `function pcipcwd_get_option_switches`, `function pcipcwd_show_card_info`, `function pcipcwd_start`, `function pcipcwd_stop`, `function pcipcwd_keepalive`, `function pcipcwd_set_heartbeat`, `function pcipcwd_get_status`, `function pcipcwd_clear_status`.
- 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.