drivers/comedi/drivers/ni_labpc_isadma.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_labpc_isadma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_labpc_isadma.c- Extension
.c- Size
- 4717 bytes
- Lines
- 170
- 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/slab.hlinux/comedi/comedidev.hlinux/comedi/comedi_isadma.hni_labpc.hni_labpc_regs.hni_labpc_isadma.h
Detected Declarations
function Copyrightfunction labpc_setup_dmafunction labpc_drain_dmafunction handle_isa_dmafunction labpc_handle_dma_statusfunction labpc_init_dma_chanfunction labpc_free_dma_chanexport labpc_setup_dmaexport labpc_drain_dmaexport labpc_handle_dma_statusexport labpc_init_dma_chanexport labpc_free_dma_chan
Annotated Snippet
if (devpriv->count <= nsamples) {
nsamples = devpriv->count;
leftover = 0;
} else {
leftover = devpriv->count - nsamples;
if (leftover > max_samples)
leftover = max_samples;
}
devpriv->count -= nsamples;
} else {
leftover = max_samples;
}
desc->size = comedi_samples_to_bytes(s, leftover);
comedi_buf_write_samples(s, desc->virt_addr, nsamples);
}
EXPORT_SYMBOL_GPL(labpc_drain_dma);
static void handle_isa_dma(struct comedi_device *dev)
{
struct labpc_private *devpriv = dev->private;
struct comedi_isadma_desc *desc = &devpriv->dma->desc[0];
labpc_drain_dma(dev);
if (desc->size)
comedi_isadma_program(desc);
/* clear dma tc interrupt */
devpriv->write_byte(dev, 0x1, DMATC_CLEAR_REG);
}
void labpc_handle_dma_status(struct comedi_device *dev)
{
const struct labpc_boardinfo *board = dev->board_ptr;
struct labpc_private *devpriv = dev->private;
/*
* if a dma terminal count of external stop trigger
* has occurred
*/
if (devpriv->stat1 & STAT1_GATA0 ||
(board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1))
handle_isa_dma(dev);
}
EXPORT_SYMBOL_GPL(labpc_handle_dma_status);
void labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan)
{
struct labpc_private *devpriv = dev->private;
/* only DMA channels 3 and 1 are valid */
if (dma_chan != 1 && dma_chan != 3)
return;
/* DMA uses 1 buffer */
devpriv->dma = comedi_isadma_alloc(dev, 1, dma_chan, dma_chan,
LABPC_ISADMA_BUFFER_SIZE,
COMEDI_ISADMA_READ);
}
EXPORT_SYMBOL_GPL(labpc_init_dma_chan);
void labpc_free_dma_chan(struct comedi_device *dev)
{
struct labpc_private *devpriv = dev->private;
if (devpriv)
comedi_isadma_free(devpriv->dma);
}
EXPORT_SYMBOL_GPL(labpc_free_dma_chan);
MODULE_AUTHOR("Comedi https://www.comedi.org");
MODULE_DESCRIPTION("Comedi NI Lab-PC ISA DMA support");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_isadma.h`, `ni_labpc.h`, `ni_labpc_regs.h`, `ni_labpc_isadma.h`.
- Detected declarations: `function Copyright`, `function labpc_setup_dma`, `function labpc_drain_dma`, `function handle_isa_dma`, `function labpc_handle_dma_status`, `function labpc_init_dma_chan`, `function labpc_free_dma_chan`, `export labpc_setup_dma`, `export labpc_drain_dma`, `export labpc_handle_dma_status`.
- 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.