drivers/comedi/drivers/addi_watchdog.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/addi_watchdog.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/addi_watchdog.c- Extension
.c- Size
- 3212 bytes
- Lines
- 130
- Domain
- Driver Families
- Bucket
- drivers/comedi
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.haddi_tcw.haddi_watchdog.h
Detected Declarations
struct addi_watchdog_privatefunction addi_watchdog_insn_configfunction addi_watchdog_insn_readfunction addi_watchdog_insn_writefunction addi_watchdog_resetfunction addi_watchdog_initexport addi_watchdog_resetexport addi_watchdog_init
Annotated Snippet
struct addi_watchdog_private {
unsigned long iobase;
unsigned int wdog_ctrl;
};
/*
* The watchdog subdevice is configured with two INSN_CONFIG instructions:
*
* Enable the watchdog and set the reload timeout:
* data[0] = INSN_CONFIG_ARM
* data[1] = timeout reload value
*
* Disable the watchdog:
* data[0] = INSN_CONFIG_DISARM
*/
static int addi_watchdog_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_watchdog_private *spriv = s->private;
unsigned int reload;
switch (data[0]) {
case INSN_CONFIG_ARM:
spriv->wdog_ctrl = ADDI_TCW_CTRL_ENA;
reload = data[1] & s->maxdata;
outl(reload, spriv->iobase + ADDI_TCW_RELOAD_REG);
/* Time base is 20ms, let the user know the timeout */
dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n",
20 * reload + 20);
break;
case INSN_CONFIG_DISARM:
spriv->wdog_ctrl = 0;
break;
default:
return -EINVAL;
}
outl(spriv->wdog_ctrl, spriv->iobase + ADDI_TCW_CTRL_REG);
return insn->n;
}
static int addi_watchdog_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_watchdog_private *spriv = s->private;
int i;
for (i = 0; i < insn->n; i++)
data[i] = inl(spriv->iobase + ADDI_TCW_STATUS_REG);
return insn->n;
}
static int addi_watchdog_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct addi_watchdog_private *spriv = s->private;
int i;
if (spriv->wdog_ctrl == 0) {
dev_warn(dev->class_dev, "watchdog is disabled\n");
return -EINVAL;
}
/* "ping" the watchdog */
for (i = 0; i < insn->n; i++) {
outl(spriv->wdog_ctrl | ADDI_TCW_CTRL_TRIG,
spriv->iobase + ADDI_TCW_CTRL_REG);
}
return insn->n;
}
void addi_watchdog_reset(unsigned long iobase)
{
outl(0x0, iobase + ADDI_TCW_CTRL_REG);
outl(0x0, iobase + ADDI_TCW_RELOAD_REG);
}
EXPORT_SYMBOL_GPL(addi_watchdog_reset);
int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`, `addi_tcw.h`, `addi_watchdog.h`.
- Detected declarations: `struct addi_watchdog_private`, `function addi_watchdog_insn_config`, `function addi_watchdog_insn_read`, `function addi_watchdog_insn_write`, `function addi_watchdog_reset`, `function addi_watchdog_init`, `export addi_watchdog_reset`, `export addi_watchdog_init`.
- Atlas domain: Driver Families / drivers/comedi.
- 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.