drivers/comedi/drivers/amplc_dio200_common.c

Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/amplc_dio200_common.c

File Facts

System
Linux kernel
Corpus path
drivers/comedi/drivers/amplc_dio200_common.c
Extension
.c
Size
23264 bytes
Lines
907
Domain
Driver Families
Bucket
drivers/comedi
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct dio200_subdev_8255 {
	unsigned int ofs;		/* DIO base offset */
};

struct dio200_subdev_intr {
	spinlock_t spinlock;	/* protects the 'active' flag */
	unsigned int ofs;
	unsigned int valid_isns;
	unsigned int enabled_isns;
	unsigned int active:1;
};

#ifdef CONFIG_HAS_IOPORT

static unsigned char dio200___read8(struct comedi_device *dev,
				    unsigned int offset)
{
	if (dev->mmio)
		return readb(dev->mmio + offset);
	return inb(dev->iobase + offset);
}

static void dio200___write8(struct comedi_device *dev,
			    unsigned int offset, unsigned char val)
{
	if (dev->mmio)
		writeb(val, dev->mmio + offset);
	else
		outb(val, dev->iobase + offset);
}

static unsigned int dio200___read32(struct comedi_device *dev,
				    unsigned int offset)
{
	if (dev->mmio)
		return readl(dev->mmio + offset);
	return inl(dev->iobase + offset);
}

static void dio200___write32(struct comedi_device *dev,
			     unsigned int offset, unsigned int val)
{
	if (dev->mmio)
		writel(val, dev->mmio + offset);
	else
		outl(val, dev->iobase + offset);
}

#else /* CONFIG_HAS_IOPORT */

static unsigned char dio200___read8(struct comedi_device *dev,
				    unsigned int offset)
{
	return readb(dev->mmio + offset);
}

static void dio200___write8(struct comedi_device *dev,
			    unsigned int offset, unsigned char val)
{
	writeb(val, dev->mmio + offset);
}

static unsigned int dio200___read32(struct comedi_device *dev,
				    unsigned int offset)
{
	return readl(dev->mmio + offset);
}

static void dio200___write32(struct comedi_device *dev,
			     unsigned int offset, unsigned int val)
{
	writel(val, dev->mmio + offset);
}

#endif /* CONFIG_HAS_IOPORT */

static unsigned char dio200_read8(struct comedi_device *dev,
				  unsigned int offset)
{
	const struct dio200_board *board = dev->board_ptr;

	if (board->is_pcie)
		offset <<= 3;

	return dio200___read8(dev, offset);
}

static void dio200_write8(struct comedi_device *dev,
			  unsigned int offset, unsigned char val)
{

Annotation

Implementation Notes