drivers/comedi/drivers/rti802.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/rti802.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/rti802.c- Extension
.c- Size
- 2897 bytes
- Lines
- 122
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.h
Detected Declarations
struct rti802_privatefunction rti802_ao_insn_writefunction rti802_attach
Annotated Snippet
struct rti802_private {
enum {
dac_2comp, dac_straight
} dac_coding[8];
const struct comedi_lrange *range_type_list[8];
};
static int rti802_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct rti802_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
int i;
outb(chan, dev->iobase + RTI802_SELECT);
for (i = 0; i < insn->n; i++) {
unsigned int val = data[i];
s->readback[chan] = val;
/* munge offset binary to two's complement if needed */
if (devpriv->dac_coding[chan] == dac_2comp)
val = comedi_offset_munge(s, val);
outb(val & 0xff, dev->iobase + RTI802_DATALOW);
outb((val >> 8) & 0xff, dev->iobase + RTI802_DATAHIGH);
}
return insn->n;
}
static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct rti802_private *devpriv;
struct comedi_subdevice *s;
int i;
int ret;
ret = comedi_check_request_region(dev, it->options[0], 0x04,
0, 0x3ff, 4);
if (ret)
return ret;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_alloc_subdevices(dev, 1);
if (ret)
return ret;
/* Analog Output subdevice */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->maxdata = 0xfff;
s->n_chan = 8;
s->insn_write = rti802_ao_insn_write;
ret = comedi_alloc_subdev_readback(s);
if (ret)
return ret;
s->range_table_list = devpriv->range_type_list;
for (i = 0; i < 8; i++) {
devpriv->dac_coding[i] = (it->options[3 + 2 * i])
? (dac_straight) : (dac_2comp);
devpriv->range_type_list[i] = (it->options[2 + 2 * i])
? &range_unipolar10 : &range_bipolar10;
}
return 0;
}
static struct comedi_driver rti802_driver = {
.driver_name = "rti802",
.module = THIS_MODULE,
.attach = rti802_attach,
.detach = comedi_legacy_detach,
};
module_comedi_driver(rti802_driver);
MODULE_AUTHOR("Comedi https://www.comedi.org");
MODULE_DESCRIPTION("Comedi driver for Analog Devices RTI-802 board");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `struct rti802_private`, `function rti802_ao_insn_write`, `function rti802_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source 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.