drivers/comedi/drivers/amplc_pc236_common.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/amplc_pc236_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/amplc_pc236_common.c- Extension
.c- Size
- 4668 bytes
- Lines
- 182
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/comedi/comedi_8255.hamplc_pc236.h
Detected Declarations
function Copyrightfunction pc236_intr_checkfunction pc236_intr_insnfunction pc236_intr_cmdtestfunction pc236_intr_cmdfunction pc236_intr_cancelfunction pc236_interruptfunction amplc_pc236_common_attachexport amplc_pc236_common_attach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* comedi/drivers/amplc_pc236_common.c
* Common support code for "amplc_pc236" and "amplc_pci236".
*
* Copyright (C) 2002-2014 MEV Ltd. <https://www.mev.co.uk/>
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 2000 David A. Schleef <ds@schleef.org>
*/
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/comedi/comedidev.h>
#include <linux/comedi/comedi_8255.h>
#include "amplc_pc236.h"
static void pc236_intr_update(struct comedi_device *dev, bool enable)
{
const struct pc236_board *board = dev->board_ptr;
struct pc236_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
devpriv->enable_irq = enable;
if (board->intr_update_cb)
board->intr_update_cb(dev, enable);
spin_unlock_irqrestore(&dev->spinlock, flags);
}
/*
* This function is called when an interrupt occurs to check whether
* the interrupt has been marked as enabled and was generated by the
* board. If so, the function prepares the hardware for the next
* interrupt.
* Returns false if the interrupt should be ignored.
*/
static bool pc236_intr_check(struct comedi_device *dev)
{
const struct pc236_board *board = dev->board_ptr;
struct pc236_private *devpriv = dev->private;
bool retval = false;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
if (devpriv->enable_irq) {
if (board->intr_chk_clr_cb)
retval = board->intr_chk_clr_cb(dev);
else
retval = true;
}
spin_unlock_irqrestore(&dev->spinlock, flags);
return retval;
}
static int pc236_intr_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
data[1] = 0;
return insn->n;
}
static int pc236_intr_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
int err = 0;
/* Step 1 : check if triggers are trivially valid */
err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
if (err)
return 1;
/* Step 2a : make sure trigger sources are unique */
/* Step 2b : and mutually compatible */
/* Step 3: check it arguments are trivially valid */
err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`, `linux/comedi/comedi_8255.h`, `amplc_pc236.h`.
- Detected declarations: `function Copyright`, `function pc236_intr_check`, `function pc236_intr_insn`, `function pc236_intr_cmdtest`, `function pc236_intr_cmd`, `function pc236_intr_cancel`, `function pc236_interrupt`, `function amplc_pc236_common_attach`, `export amplc_pc236_common_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: integration 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.