drivers/watchdog/nct6694_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/nct6694_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/nct6694_wdt.c- Extension
.c- Size
- 7825 bytes
- Lines
- 308
- 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/idr.hlinux/kernel.hlinux/mfd/nct6694.hlinux/module.hlinux/platform_device.hlinux/slab.hlinux/watchdog.h
Detected Declarations
struct nct6694_wdt_datafunction nct6694_wdt_settingfunction nct6694_wdt_startfunction nct6694_wdt_stopfunction nct6694_wdt_pingfunction nct6694_wdt_set_timeoutfunction nct6694_wdt_set_pretimeoutfunction nct6694_wdt_get_timefunction nct6694_wdt_ida_freefunction nct6694_wdt_probe
Annotated Snippet
struct nct6694_wdt_data {
struct watchdog_device wdev;
struct device *dev;
struct nct6694 *nct6694;
union nct6694_wdt_msg *msg;
unsigned char wdev_idx;
};
static int nct6694_wdt_setting(struct watchdog_device *wdev,
u32 timeout_val, u8 timeout_act,
u32 pretimeout_val, u8 pretimeout_act)
{
struct nct6694_wdt_data *data = watchdog_get_drvdata(wdev);
struct nct6694_wdt_setup *setup = &data->msg->setup;
const struct nct6694_cmd_header cmd_hd = {
.mod = NCT6694_WDT_MOD,
.cmd = NCT6694_WDT_SETUP,
.sel = NCT6694_WDT_SETUP_SEL(data->wdev_idx),
.len = cpu_to_le16(sizeof(*setup))
};
unsigned int timeout_fmt, pretimeout_fmt;
if (pretimeout_val == 0)
pretimeout_act = NCT6694_ACTION_NONE;
timeout_fmt = (timeout_val * 1000) | (timeout_act << 24);
pretimeout_fmt = (pretimeout_val * 1000) | (pretimeout_act << 24);
memset(setup, 0, sizeof(*setup));
setup->timeout = cpu_to_le32(timeout_fmt);
setup->pretimeout = cpu_to_le32(pretimeout_fmt);
return nct6694_write_msg(data->nct6694, &cmd_hd, setup);
}
static int nct6694_wdt_start(struct watchdog_device *wdev)
{
struct nct6694_wdt_data *data = watchdog_get_drvdata(wdev);
int ret;
ret = nct6694_wdt_setting(wdev, wdev->timeout, NCT6694_ACTION_GPO,
wdev->pretimeout, NCT6694_ACTION_GPO);
if (ret)
return ret;
dev_dbg(data->dev, "Setting WDT(%d): timeout = %d, pretimeout = %d\n",
data->wdev_idx, wdev->timeout, wdev->pretimeout);
return ret;
}
static int nct6694_wdt_stop(struct watchdog_device *wdev)
{
struct nct6694_wdt_data *data = watchdog_get_drvdata(wdev);
struct nct6694_wdt_cmd *cmd = &data->msg->cmd;
const struct nct6694_cmd_header cmd_hd = {
.mod = NCT6694_WDT_MOD,
.cmd = NCT6694_WDT_COMMAND,
.sel = NCT6694_WDT_COMMAND_SEL(data->wdev_idx),
.len = cpu_to_le16(sizeof(*cmd))
};
memcpy(&cmd->wdt_cmd, "WDTC", 4);
cmd->reserved = 0;
return nct6694_write_msg(data->nct6694, &cmd_hd, cmd);
}
static int nct6694_wdt_ping(struct watchdog_device *wdev)
{
struct nct6694_wdt_data *data = watchdog_get_drvdata(wdev);
struct nct6694_wdt_cmd *cmd = &data->msg->cmd;
const struct nct6694_cmd_header cmd_hd = {
.mod = NCT6694_WDT_MOD,
.cmd = NCT6694_WDT_COMMAND,
.sel = NCT6694_WDT_COMMAND_SEL(data->wdev_idx),
.len = cpu_to_le16(sizeof(*cmd))
};
memcpy(&cmd->wdt_cmd, "WDTS", 4);
cmd->reserved = 0;
return nct6694_write_msg(data->nct6694, &cmd_hd, cmd);
}
static int nct6694_wdt_set_timeout(struct watchdog_device *wdev,
unsigned int new_timeout)
{
int ret;
Annotation
- Immediate include surface: `linux/idr.h`, `linux/kernel.h`, `linux/mfd/nct6694.h`, `linux/module.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/watchdog.h`.
- Detected declarations: `struct nct6694_wdt_data`, `function nct6694_wdt_setting`, `function nct6694_wdt_start`, `function nct6694_wdt_stop`, `function nct6694_wdt_ping`, `function nct6694_wdt_set_timeout`, `function nct6694_wdt_set_pretimeout`, `function nct6694_wdt_get_time`, `function nct6694_wdt_ida_free`, `function nct6694_wdt_probe`.
- 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.