drivers/comedi/drivers/dt2814.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/dt2814.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/dt2814.c- Extension
.c- Size
- 8768 bytes
- Lines
- 373
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/delay.h
Detected Declarations
function Copyrightfunction dt2814_ai_clearfunction dt2814_ai_eocfunction dt2814_ai_insn_readfunction dt2814_ns_to_timerfunction dt2814_ai_cmdtestfunction dt2814_ai_cmdfunction dt2814_ai_cancelfunction dt2814_interruptfunction dt2814_attachfunction dt2814_detach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* comedi/drivers/dt2814.c
* Hardware driver for Data Translation DT2814
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 1998 David A. Schleef <ds@schleef.org>
*/
/*
* Driver: dt2814
* Description: Data Translation DT2814
* Author: ds
* Status: complete
* Devices: [Data Translation] DT2814 (dt2814)
*
* Configuration options:
* [0] - I/O port base address
* [1] - IRQ
*
* This card has 16 analog inputs multiplexed onto a 12 bit ADC. There
* is a minimally useful onboard clock. The base frequency for the
* clock is selected by jumpers, and the clock divider can be selected
* via programmed I/O. Unfortunately, the clock divider can only be
* a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In
* addition, the clock does not seem to be very accurate.
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/comedi/comedidev.h>
#include <linux/delay.h>
#define DT2814_CSR 0
#define DT2814_DATA 1
/*
* flags
*/
#define DT2814_FINISH 0x80
#define DT2814_ERR 0x40
#define DT2814_BUSY 0x20
#define DT2814_ENB 0x10
#define DT2814_CHANMASK 0x0f
#define DT2814_TIMEOUT 10
#define DT2814_MAX_SPEED 100000 /* Arbitrary 10 khz limit */
static int dt2814_ai_notbusy(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
unsigned int status;
status = inb(dev->iobase + DT2814_CSR);
if (context)
*(unsigned int *)context = status;
if (status & DT2814_BUSY)
return -EBUSY;
return 0;
}
static int dt2814_ai_clear(struct comedi_device *dev)
{
unsigned int status = 0;
int ret;
/* Wait until not busy and get status register value. */
ret = comedi_timeout(dev, NULL, NULL, dt2814_ai_notbusy,
(unsigned long)&status);
if (ret)
return ret;
if (status & (DT2814_FINISH | DT2814_ERR)) {
/*
* There unread data, or the error flag is set.
* Read the data register twice to clear the condition.
*/
inb(dev->iobase + DT2814_DATA);
inb(dev->iobase + DT2814_DATA);
}
return 0;
}
static int dt2814_ai_eoc(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned long context)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`, `linux/delay.h`.
- Detected declarations: `function Copyright`, `function dt2814_ai_clear`, `function dt2814_ai_eoc`, `function dt2814_ai_insn_read`, `function dt2814_ns_to_timer`, `function dt2814_ai_cmdtest`, `function dt2814_ai_cmd`, `function dt2814_ai_cancel`, `function dt2814_interrupt`, `function dt2814_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.