drivers/comedi/drivers/dt2817.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/dt2817.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/dt2817.c- Extension
.c- Size
- 3239 bytes
- Lines
- 142
- 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
function Copyrightfunction dt2817_dio_insn_bitsfunction dt2817_attach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* comedi/drivers/dt2817.c
* Hardware driver for Data Translation DT2817
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 1998 David A. Schleef <ds@schleef.org>
*/
/*
* Driver: dt2817
* Description: Data Translation DT2817
* Author: ds
* Status: complete
* Devices: [Data Translation] DT2817 (dt2817)
*
* A very simple digital I/O card. Four banks of 8 lines, each bank
* is configurable for input or output. One wonders why it takes a
* 50 page manual to describe this thing.
*
* The driver (which, btw, is much less than 50 pages) has 1 subdevice
* with 32 channels, configurable in groups of 8.
*
* Configuration options:
* [0] - I/O port base base address
*/
#include <linux/module.h>
#include <linux/comedi/comedidev.h>
#define DT2817_CR 0
#define DT2817_DATA 1
static int dt2817_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int oe = 0;
unsigned int mask;
int ret;
if (chan < 8)
mask = 0x000000ff;
else if (chan < 16)
mask = 0x0000ff00;
else if (chan < 24)
mask = 0x00ff0000;
else
mask = 0xff000000;
ret = comedi_dio_insn_config(dev, s, insn, data, mask);
if (ret)
return ret;
if (s->io_bits & 0x000000ff)
oe |= 0x1;
if (s->io_bits & 0x0000ff00)
oe |= 0x2;
if (s->io_bits & 0x00ff0000)
oe |= 0x4;
if (s->io_bits & 0xff000000)
oe |= 0x8;
outb(oe, dev->iobase + DT2817_CR);
return insn->n;
}
static int dt2817_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned long iobase = dev->iobase + DT2817_DATA;
unsigned int mask;
unsigned int val;
mask = comedi_dio_update_state(s, data);
if (mask) {
if (mask & 0x000000ff)
outb(s->state & 0xff, iobase + 0);
if (mask & 0x0000ff00)
outb((s->state >> 8) & 0xff, iobase + 1);
if (mask & 0x00ff0000)
outb((s->state >> 16) & 0xff, iobase + 2);
if (mask & 0xff000000)
outb((s->state >> 24) & 0xff, iobase + 3);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `function Copyright`, `function dt2817_dio_insn_bits`, `function dt2817_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.