drivers/comedi/drivers/ni_at_a2150.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_at_a2150.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_at_a2150.c- Extension
.c- Size
- 21565 bytes
- Lines
- 782
- 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/delay.hlinux/interrupt.hlinux/slab.hlinux/io.hlinux/comedi/comedidev.hlinux/comedi/comedi_8254.hlinux/comedi/comedi_isadma.h
Detected Declarations
struct a2150_boardstruct a2150_privatefunction a2150_interruptfunction a2150_cancelfunction a2150_get_timingfunction a2150_set_chanlistfunction a2150_ai_check_chanlistfunction a2150_ai_cmdtestfunction a2150_ai_cmdfunction a2150_ai_eocfunction a2150_ai_rinsnfunction a2150_alloc_irq_and_dmafunction a2150_free_dmafunction a2150_attachfunction a2150_detach
Annotated Snippet
struct a2150_board {
const char *name;
int clock[4]; /* master clock periods, in nanoseconds */
int num_clocks; /* number of available master clock speeds */
int ai_speed; /* maximum conversion rate in nanoseconds */
};
/* analog input range */
static const struct comedi_lrange range_a2150 = {
1, {
BIP_RANGE(2.828)
}
};
/* enum must match board indices */
enum { a2150_c, a2150_s };
static const struct a2150_board a2150_boards[] = {
{
.name = "at-a2150c",
.clock = {31250, 22676, 20833, 19531},
.num_clocks = 4,
.ai_speed = 19531,
},
{
.name = "at-a2150s",
.clock = {62500, 50000, 41667, 0},
.num_clocks = 3,
.ai_speed = 41667,
},
};
struct a2150_private {
struct comedi_isadma *dma;
unsigned int count; /* number of data points left to be taken */
int irq_dma_bits; /* irq/dma register bits */
int config_bits; /* config register bits */
};
/* interrupt service routine */
static irqreturn_t a2150_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct a2150_private *devpriv = dev->private;
struct comedi_isadma *dma = devpriv->dma;
struct comedi_isadma_desc *desc = &dma->desc[0];
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned short *buf = desc->virt_addr;
unsigned int max_points, num_points, residue, leftover;
unsigned short dpnt;
int status;
int i;
if (!dev->attached)
return IRQ_HANDLED;
status = inw(dev->iobase + STATUS_REG);
if ((status & INTR_BIT) == 0)
return IRQ_NONE;
if (status & OVFL_BIT) {
async->events |= COMEDI_CB_ERROR;
comedi_handle_events(dev, s);
}
if ((status & DMA_TC_BIT) == 0) {
async->events |= COMEDI_CB_ERROR;
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
/*
* residue is the number of bytes left to be done on the dma
* transfer. It should always be zero at this point unless
* the stop_src is set to external triggering.
*/
residue = comedi_isadma_disable(desc->chan);
/* figure out how many points to read */
max_points = comedi_bytes_to_samples(s, desc->size);
num_points = max_points - comedi_bytes_to_samples(s, residue);
if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT)
num_points = devpriv->count;
/* figure out how many points will be stored next time */
leftover = 0;
if (cmd->stop_src == TRIG_NONE) {
leftover = comedi_bytes_to_samples(s, desc->size);
} else if (devpriv->count > max_points) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/io.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8254.h`, `linux/comedi/comedi_isadma.h`.
- Detected declarations: `struct a2150_board`, `struct a2150_private`, `function a2150_interrupt`, `function a2150_cancel`, `function a2150_get_timing`, `function a2150_set_chanlist`, `function a2150_ai_check_chanlist`, `function a2150_ai_cmdtest`, `function a2150_ai_cmd`, `function a2150_ai_eoc`.
- 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.