drivers/comedi/drivers/vmk80xx.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/vmk80xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/vmk80xx.c- Extension
.c- Size
- 20292 bytes
- Lines
- 871
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/mutex.hlinux/errno.hlinux/input.hlinux/slab.hlinux/poll.hlinux/uaccess.hlinux/comedi/comedi_usb.h
Detected Declarations
struct vmk80xx_boardstruct vmk80xx_privateenum vmk80xx_modelfunction vmk80xx_do_bulk_msgfunction vmk80xx_read_packetfunction vmk80xx_write_packetfunction vmk80xx_reset_devicefunction vmk80xx_ai_insn_readfunction vmk80xx_ao_insn_writefunction vmk80xx_ao_insn_readfunction vmk80xx_di_insn_bitsfunction vmk80xx_do_insn_bitsfunction vmk80xx_cnt_insn_readfunction vmk80xx_cnt_insn_configfunction vmk80xx_cnt_insn_writefunction vmk80xx_pwm_insn_readfunction vmk80xx_pwm_insn_writefunction vmk80xx_find_usb_endpointsfunction vmk80xx_alloc_usb_buffersfunction vmk80xx_init_subdevicesfunction vmk80xx_auto_attachfunction vmk80xx_detachfunction vmk80xx_usb_probe
Annotated Snippet
struct vmk80xx_board {
const char *name;
enum vmk80xx_model model;
const struct comedi_lrange *range;
int ai_nchans;
unsigned int ai_maxdata;
int ao_nchans;
int di_nchans;
unsigned int cnt_maxdata;
int pwm_nchans;
unsigned int pwm_maxdata;
};
static const struct vmk80xx_board vmk80xx_boardinfo[] = {
[DEVICE_VMK8055] = {
.name = "K8055 (VM110)",
.model = VMK8055_MODEL,
.range = &range_unipolar5,
.ai_nchans = 2,
.ai_maxdata = 0x00ff,
.ao_nchans = 2,
.di_nchans = 6,
.cnt_maxdata = 0xffff,
},
[DEVICE_VMK8061] = {
.name = "K8061 (VM140)",
.model = VMK8061_MODEL,
.range = &vmk8061_range,
.ai_nchans = 8,
.ai_maxdata = 0x03ff,
.ao_nchans = 8,
.di_nchans = 8,
.cnt_maxdata = 0, /* unknown, device is not writeable */
.pwm_nchans = 1,
.pwm_maxdata = 0x03ff,
},
};
struct vmk80xx_private {
struct usb_endpoint_descriptor *ep_rx;
struct usb_endpoint_descriptor *ep_tx;
struct semaphore limit_sem;
unsigned char *usb_rx_buf;
unsigned char *usb_tx_buf;
enum vmk80xx_model model;
};
static void vmk80xx_do_bulk_msg(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb = comedi_to_usb_dev(dev);
__u8 tx_addr;
__u8 rx_addr;
unsigned int tx_pipe;
unsigned int rx_pipe;
size_t tx_size;
size_t rx_size;
tx_addr = devpriv->ep_tx->bEndpointAddress;
rx_addr = devpriv->ep_rx->bEndpointAddress;
tx_pipe = usb_sndbulkpipe(usb, tx_addr);
rx_pipe = usb_rcvbulkpipe(usb, rx_addr);
tx_size = usb_endpoint_maxp(devpriv->ep_tx);
rx_size = usb_endpoint_maxp(devpriv->ep_rx);
usb_bulk_msg(usb, tx_pipe, devpriv->usb_tx_buf, tx_size, NULL,
PACKET_TIMEOUT);
usb_bulk_msg(usb, rx_pipe, devpriv->usb_rx_buf, rx_size, NULL,
PACKET_TIMEOUT);
}
static int vmk80xx_read_packet(struct comedi_device *dev)
{
struct vmk80xx_private *devpriv = dev->private;
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usb_endpoint_descriptor *ep;
unsigned int pipe;
if (devpriv->model == VMK8061_MODEL) {
vmk80xx_do_bulk_msg(dev);
return 0;
}
ep = devpriv->ep_rx;
pipe = usb_rcvintpipe(usb, ep->bEndpointAddress);
return usb_interrupt_msg(usb, pipe, devpriv->usb_rx_buf,
usb_endpoint_maxp(ep), NULL,
PACKET_TIMEOUT);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/errno.h`, `linux/input.h`, `linux/slab.h`, `linux/poll.h`, `linux/uaccess.h`.
- Detected declarations: `struct vmk80xx_board`, `struct vmk80xx_private`, `enum vmk80xx_model`, `function vmk80xx_do_bulk_msg`, `function vmk80xx_read_packet`, `function vmk80xx_write_packet`, `function vmk80xx_reset_device`, `function vmk80xx_ai_insn_read`, `function vmk80xx_ao_insn_write`, `function vmk80xx_ao_insn_read`.
- 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.