drivers/comedi/drivers/aio_iiro_16.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/aio_iiro_16.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/aio_iiro_16.c- Extension
.c- Size
- 6153 bytes
- Lines
- 237
- 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.
- 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.h
Detected Declarations
function Copyrightfunction aio_iiro_16_cosfunction aio_iiro_enable_irqfunction aio_iiro_16_cos_cancelfunction aio_iiro_16_cos_cmdfunction aio_iiro_16_cos_cmdtestfunction aio_iiro_16_do_insn_bitsfunction aio_iiro_16_di_insn_bitsfunction aio_iiro_16_attach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* aio_iiro_16.c
* Comedi driver for ACCES I/O Products 104-IIRO-16 board
* Copyright (C) 2006 C&C Technologies, Inc.
*/
/*
* Driver: aio_iiro_16
* Description: ACCES I/O Products PC/104 Isolated Input/Relay Output Board
* Author: Zachary Ware <zach.ware@cctechnol.com>
* Devices: [ACCES I/O] 104-IIRO-16 (aio_iiro_16)
* Status: experimental
*
* Configuration Options:
* [0] - I/O port base address
* [1] - IRQ (optional)
*
* The board supports interrupts on change of state of the digital inputs.
* The sample data returned by the async command indicates which inputs
* changed state and the current state of the inputs:
*
* Bit 23 - IRQ Enable (1) / Disable (0)
* Bit 17 - Input 8-15 Changed State (1 = Changed, 0 = No Change)
* Bit 16 - Input 0-7 Changed State (1 = Changed, 0 = No Change)
* Bit 15 - Digital input 15
* ...
* Bit 0 - Digital input 0
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/comedi/comedidev.h>
#define AIO_IIRO_16_RELAY_0_7 0x00
#define AIO_IIRO_16_INPUT_0_7 0x01
#define AIO_IIRO_16_IRQ 0x02
#define AIO_IIRO_16_RELAY_8_15 0x04
#define AIO_IIRO_16_INPUT_8_15 0x05
#define AIO_IIRO_16_STATUS 0x07
#define AIO_IIRO_16_STATUS_IRQE BIT(7)
#define AIO_IIRO_16_STATUS_INPUT_8_15 BIT(1)
#define AIO_IIRO_16_STATUS_INPUT_0_7 BIT(0)
static unsigned int aio_iiro_16_read_inputs(struct comedi_device *dev)
{
unsigned int val;
val = inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
val |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
return val;
}
static irqreturn_t aio_iiro_16_cos(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
unsigned int status;
unsigned int val;
status = inb(dev->iobase + AIO_IIRO_16_STATUS);
if (!(status & AIO_IIRO_16_STATUS_IRQE))
return IRQ_NONE;
val = aio_iiro_16_read_inputs(dev);
val |= (status << 16);
comedi_buf_write_samples(s, &val, 1);
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
static void aio_iiro_enable_irq(struct comedi_device *dev, bool enable)
{
if (enable)
inb(dev->iobase + AIO_IIRO_16_IRQ);
else
outb(0, dev->iobase + AIO_IIRO_16_IRQ);
}
static int aio_iiro_16_cos_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
aio_iiro_enable_irq(dev, false);
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `function Copyright`, `function aio_iiro_16_cos`, `function aio_iiro_enable_irq`, `function aio_iiro_16_cos_cancel`, `function aio_iiro_16_cos_cmd`, `function aio_iiro_16_cos_cmdtest`, `function aio_iiro_16_do_insn_bits`, `function aio_iiro_16_di_insn_bits`, `function aio_iiro_16_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
- 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.