drivers/watchdog/wdat_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/wdat_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/wdat_wdt.c- Extension
.c- Size
- 13940 bytes
- Lines
- 572
- Domain
- Driver Families
- Bucket
- drivers/watchdog
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/ioport.hlinux/module.hlinux/platform_device.hlinux/pm.hlinux/watchdog.h
Detected Declarations
struct wdat_instructionstruct wdat_wdtfunction wdat_wdt_readfunction wdat_wdt_writefunction wdat_wdt_run_actionfunction wdat_wdt_enable_rebootfunction wdat_wdt_boot_statusfunction wdat_wdt_set_runningfunction wdat_wdt_startfunction wdat_wdt_stopfunction wdat_wdt_pingfunction wdat_wdt_set_timeoutfunction wdat_wdt_get_timeleftfunction wdat_wdt_probefunction wdat_wdt_suspend_noirqfunction wdat_wdt_resume_noirq
Annotated Snippet
struct wdat_instruction {
struct acpi_wdat_entry entry;
void __iomem *reg;
struct list_head node;
};
/**
* struct wdat_wdt - ACPI WDAT watchdog device
* @pdev: Parent platform device
* @wdd: Watchdog core device
* @period: How long is one watchdog period in ms
* @stopped_in_sleep: Is this watchdog stopped by the firmware in S1-S5
* @stopped: Was the watchdog stopped by the driver in suspend
* @instructions: An array of instruction lists indexed by an action number from
* the WDAT table. There can be %NULL entries for not implemented
* actions.
*/
struct wdat_wdt {
struct platform_device *pdev;
struct watchdog_device wdd;
unsigned int period;
bool stopped_in_sleep;
bool stopped;
struct list_head *instructions[MAX_WDAT_ACTIONS];
};
#define to_wdat_wdt(wdd) container_of(wdd, struct wdat_wdt, wdd)
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
#define WDAT_DEFAULT_TIMEOUT 30
static int timeout = WDAT_DEFAULT_TIMEOUT;
module_param(timeout, int, 0);
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
__MODULE_STRING(WDAT_DEFAULT_TIMEOUT) ")");
static int wdat_wdt_read(struct wdat_wdt *wdat,
const struct wdat_instruction *instr, u32 *value)
{
const struct acpi_generic_address *gas = &instr->entry.register_region;
switch (gas->access_width) {
case 1:
*value = ioread8(instr->reg);
break;
case 2:
*value = ioread16(instr->reg);
break;
case 3:
*value = ioread32(instr->reg);
break;
default:
return -EINVAL;
}
dev_dbg(&wdat->pdev->dev, "Read %#x from 0x%08llx\n", *value,
gas->address);
return 0;
}
static int wdat_wdt_write(struct wdat_wdt *wdat,
const struct wdat_instruction *instr, u32 value)
{
const struct acpi_generic_address *gas = &instr->entry.register_region;
switch (gas->access_width) {
case 1:
iowrite8((u8)value, instr->reg);
break;
case 2:
iowrite16((u16)value, instr->reg);
break;
case 3:
iowrite32(value, instr->reg);
break;
default:
return -EINVAL;
}
dev_dbg(&wdat->pdev->dev, "Wrote %#x to 0x%08llx\n", value,
gas->address);
return 0;
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/ioport.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm.h`, `linux/watchdog.h`.
- Detected declarations: `struct wdat_instruction`, `struct wdat_wdt`, `function wdat_wdt_read`, `function wdat_wdt_write`, `function wdat_wdt_run_action`, `function wdat_wdt_enable_reboot`, `function wdat_wdt_boot_status`, `function wdat_wdt_set_running`, `function wdat_wdt_start`, `function wdat_wdt_stop`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
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.