drivers/comedi/drivers/das6402.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/das6402.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/das6402.c- Extension
.c- Size
- 17873 bytes
- Lines
- 670
- Domain
- Driver Families
- Bucket
- drivers/comedi
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/interrupt.hlinux/comedi/comedidev.hlinux/comedi/comedi_8254.h
Detected Declarations
struct das6402_boardinfostruct das6402_privatefunction das6402_set_modefunction das6402_set_extendedfunction das6402_clear_all_interruptsfunction das6402_ai_clear_eocfunction das6402_ai_read_samplefunction das6402_interruptfunction das6402_ai_set_modefunction das6402_ai_cmdfunction das6402_ai_check_chanlistfunction das6402_ai_cmdtestfunction das6402_ai_cancelfunction das6402_ai_soft_trigfunction das6402_ai_eocfunction das6402_ai_insn_readfunction das6402_ao_insn_writefunction das6402_ao_insn_readfunction das6402_di_insn_bitsfunction das6402_do_insn_bitsfunction das6402_resetfunction das6402_attach
Annotated Snippet
struct das6402_boardinfo {
const char *name;
unsigned int maxdata;
};
static struct das6402_boardinfo das6402_boards[] = {
{
.name = "das6402-12",
.maxdata = 0x0fff,
}, {
.name = "das6402-16",
.maxdata = 0xffff,
},
};
struct das6402_private {
unsigned int irq;
unsigned int ao_range;
};
static void das6402_set_mode(struct comedi_device *dev,
unsigned int mode)
{
outb(DAS6402_MODE_ENHANCED | mode, dev->iobase + DAS6402_MODE_REG);
}
static void das6402_set_extended(struct comedi_device *dev,
unsigned int val)
{
outb(DAS6402_STATUS_W_EXTEND, dev->iobase + DAS6402_STATUS_REG);
outb(DAS6402_STATUS_W_EXTEND | val, dev->iobase + DAS6402_STATUS_REG);
outb(val, dev->iobase + DAS6402_STATUS_REG);
}
static void das6402_clear_all_interrupts(struct comedi_device *dev)
{
outb(DAS6402_STATUS_W_CLRINT |
DAS6402_STATUS_W_CLRXTR |
DAS6402_STATUS_W_CLRXIN, dev->iobase + DAS6402_STATUS_REG);
}
static void das6402_ai_clear_eoc(struct comedi_device *dev)
{
outb(DAS6402_STATUS_W_CLRINT, dev->iobase + DAS6402_STATUS_REG);
}
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
struct comedi_subdevice *s)
{
unsigned int val;
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
if (s->maxdata == 0x0fff)
val >>= 4;
return val;
}
static irqreturn_t das6402_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int status;
status = inb(dev->iobase + DAS6402_STATUS_REG);
if ((status & DAS6402_STATUS_INT) == 0)
return IRQ_NONE;
if (status & DAS6402_STATUS_FFULL) {
async->events |= COMEDI_CB_OVERFLOW;
} else if (status & DAS6402_STATUS_FFNE) {
unsigned short val;
val = das6402_ai_read_sample(dev, s);
comedi_buf_write_samples(s, &val, 1);
if (cmd->stop_src == TRIG_COUNT &&
async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
}
das6402_clear_all_interrupts(dev);
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
static void das6402_ai_set_mode(struct comedi_device *dev,
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8254.h`.
- Detected declarations: `struct das6402_boardinfo`, `struct das6402_private`, `function das6402_set_mode`, `function das6402_set_extended`, `function das6402_clear_all_interrupts`, `function das6402_ai_clear_eoc`, `function das6402_ai_read_sample`, `function das6402_interrupt`, `function das6402_ai_set_mode`, `function das6402_ai_cmd`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.