drivers/acpi/acpi_watchdog.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpi_watchdog.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpi_watchdog.c- Extension
.c- Size
- 4587 bytes
- Lines
- 189
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/platform_device.hinternal.hlinux/mc146818rtc.h
Detected Declarations
function Copyrightfunction acpi_watchdog_uses_rtcfunction onefunction disable_acpi_watchdogfunction acpi_watchdog_initfunction resource_list_for_each_entryexport acpi_has_watchdog
Annotated Snippet
if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
switch (gas->address) {
case RTC_PORT(0):
case RTC_PORT(1):
case RTC_PORT(2):
case RTC_PORT(3):
return true;
}
}
}
return false;
}
#else
static bool acpi_watchdog_uses_rtc(const struct acpi_table_wdat *wdat)
{
return false;
}
#endif
static bool acpi_no_watchdog;
static const struct acpi_table_wdat *acpi_watchdog_get_wdat(void)
{
const struct acpi_table_wdat *wdat = NULL;
acpi_status status;
if (acpi_disabled || acpi_no_watchdog)
return NULL;
status = acpi_get_table(ACPI_SIG_WDAT, 0,
(struct acpi_table_header **)&wdat);
if (ACPI_FAILURE(status)) {
/* It is fine if there is no WDAT */
return NULL;
}
if (acpi_watchdog_uses_rtc(wdat)) {
acpi_put_table((struct acpi_table_header *)wdat);
pr_info("Skipping WDAT on this system because it uses RTC SRAM\n");
return NULL;
}
return wdat;
}
/*
* Returns true if this system should prefer ACPI based watchdog instead of
* the native one (which are typically the same hardware).
*/
bool acpi_has_watchdog(void)
{
return !!acpi_watchdog_get_wdat();
}
EXPORT_SYMBOL_GPL(acpi_has_watchdog);
/* ACPI watchdog can be disabled on boot command line */
static int __init disable_acpi_watchdog(char *str)
{
acpi_no_watchdog = true;
return 1;
}
__setup("acpi_no_watchdog", disable_acpi_watchdog);
void __init acpi_watchdog_init(void)
{
const struct acpi_wdat_entry *entries;
const struct acpi_table_wdat *wdat;
LIST_HEAD(resource_list);
struct resource_entry *rentry;
struct platform_device *pdev;
struct resource *resources;
size_t nresources = 0;
int i;
wdat = acpi_watchdog_get_wdat();
if (!wdat) {
/* It is fine if there is no WDAT */
return;
}
/* Watchdog disabled by BIOS */
if (!(wdat->flags & ACPI_WDAT_ENABLED))
goto fail_put_wdat;
/* Skip legacy PCI WDT devices */
if (wdat->pci_segment != 0xff || wdat->pci_bus != 0xff ||
wdat->pci_device != 0xff || wdat->pci_function != 0xff)
goto fail_put_wdat;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/ioport.h`, `linux/platform_device.h`, `internal.h`, `linux/mc146818rtc.h`.
- Detected declarations: `function Copyright`, `function acpi_watchdog_uses_rtc`, `function one`, `function disable_acpi_watchdog`, `function acpi_watchdog_init`, `function resource_list_for_each_entry`, `export acpi_has_watchdog`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration 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.