drivers/watchdog/ziirave_wdt.c
Source file repositories/reference/linux-study-clean/drivers/watchdog/ziirave_wdt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/watchdog/ziirave_wdt.c- Extension
.c- Size
- 18876 bytes
- Lines
- 747
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/delay.hlinux/i2c.hlinux/ihex.hlinux/firmware.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/sysfs.hlinux/types.hlinux/watchdog.hlinux/unaligned.h
Detected Declarations
struct ziirave_wdt_revstruct ziirave_wdt_datafunction ziirave_wdt_revisionfunction ziirave_wdt_set_statefunction ziirave_wdt_startfunction ziirave_wdt_stopfunction ziirave_wdt_pingfunction ziirave_wdt_set_timeoutfunction ziirave_wdt_get_timeleftfunction ziirave_firm_read_ackfunction ziirave_firm_set_read_addrfunction ziirave_firm_addr_readonlyfunction ziirave_firm_write_pktfunction ziirave_firm_write_pktfunction ziirave_firm_verifyfunction ziirave_firm_uploadfunction ziirave_wdt_sysfs_show_firmfunction ziirave_wdt_sysfs_show_bootfunction ziirave_wdt_sysfs_show_reasonfunction ziirave_wdt_sysfs_store_firmfunction ziirave_wdt_init_durationfunction ziirave_wdt_probefunction ziirave_wdt_remove
Annotated Snippet
struct ziirave_wdt_rev {
unsigned char major;
unsigned char minor;
};
struct ziirave_wdt_data {
struct mutex sysfs_mutex;
struct watchdog_device wdd;
struct ziirave_wdt_rev bootloader_rev;
struct ziirave_wdt_rev firmware_rev;
int reset_reason;
};
static int wdt_timeout;
module_param(wdt_timeout, int, 0);
MODULE_PARM_DESC(wdt_timeout, "Watchdog timeout in seconds");
static int reset_duration;
module_param(reset_duration, int, 0);
MODULE_PARM_DESC(reset_duration,
"Watchdog reset pulse duration in milliseconds");
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) ")");
static int ziirave_wdt_revision(struct i2c_client *client,
struct ziirave_wdt_rev *rev, u8 command)
{
int ret;
ret = i2c_smbus_read_byte_data(client, command);
if (ret < 0)
return ret;
rev->major = ret;
ret = i2c_smbus_read_byte_data(client, command + 1);
if (ret < 0)
return ret;
rev->minor = ret;
return 0;
}
static int ziirave_wdt_set_state(struct watchdog_device *wdd, int state)
{
struct i2c_client *client = to_i2c_client(wdd->parent);
return i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_STATE, state);
}
static int ziirave_wdt_start(struct watchdog_device *wdd)
{
return ziirave_wdt_set_state(wdd, ZIIRAVE_STATE_ON);
}
static int ziirave_wdt_stop(struct watchdog_device *wdd)
{
return ziirave_wdt_set_state(wdd, ZIIRAVE_STATE_OFF);
}
static int ziirave_wdt_ping(struct watchdog_device *wdd)
{
struct i2c_client *client = to_i2c_client(wdd->parent);
return i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_PING,
ZIIRAVE_PING_VALUE);
}
static int ziirave_wdt_set_timeout(struct watchdog_device *wdd,
unsigned int timeout)
{
struct i2c_client *client = to_i2c_client(wdd->parent);
int ret;
ret = i2c_smbus_write_byte_data(client, ZIIRAVE_WDT_TIMEOUT, timeout);
if (!ret)
wdd->timeout = timeout;
return ret;
}
static unsigned int ziirave_wdt_get_timeleft(struct watchdog_device *wdd)
{
struct i2c_client *client = to_i2c_client(wdd->parent);
int ret;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/ihex.h`, `linux/firmware.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/sysfs.h`.
- Detected declarations: `struct ziirave_wdt_rev`, `struct ziirave_wdt_data`, `function ziirave_wdt_revision`, `function ziirave_wdt_set_state`, `function ziirave_wdt_start`, `function ziirave_wdt_stop`, `function ziirave_wdt_ping`, `function ziirave_wdt_set_timeout`, `function ziirave_wdt_get_timeleft`, `function ziirave_firm_read_ack`.
- Atlas domain: Driver Families / drivers/watchdog.
- Implementation status: source implementation candidate.
- 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.