drivers/comedi/drivers/ni_tiocmd.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_tiocmd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_tiocmd.c- Extension
.c- Size
- 13983 bytes
- Lines
- 500
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hni_tio_internal.hmite.hni_routes.h
Detected Declarations
function Copyrightfunction ni_tio_input_inttrigfunction ni_tio_input_cmdfunction ni_tio_output_cmdfunction ni_tio_cmd_setupfunction ni_tio_cmdfunction ni_tio_cmdtestfunction ni_tio_cancelfunction should_ack_gatefunction ni_tio_acknowledge_and_confirmfunction ni_tio_acknowledgefunction ni_tio_handle_interruptfunction ni_tio_set_mite_channelexport ni_tio_cmdexport ni_tio_cmdtestexport ni_tio_cancelexport ni_tio_acknowledgeexport ni_tio_handle_interruptexport ni_tio_set_mite_channel
Annotated Snippet
else if (cmd->start_src == TRIG_EXT) {
int reg = CR_CHAN(cmd->start_arg);
if (reg >= NI_NAMES_BASE) {
/* using a device-global name. lookup reg */
reg = ni_get_reg_value(reg,
NI_CtrArmStartTrigger(cidx),
routing_tables);
/* mark this as a raw register value */
reg |= NI_GPCT_HW_ARM;
}
ret = ni_tio_arm(counter, true, reg);
}
}
return ret;
}
static int ni_tio_output_cmd(struct comedi_subdevice *s)
{
struct ni_gpct *counter = s->private;
dev_err(counter->counter_dev->dev->class_dev,
"output commands not yet implemented.\n");
return -ENOTSUPP;
}
static int ni_tio_cmd_setup(struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
struct ni_gpct *counter = s->private;
unsigned int cidx = counter->counter_index;
const struct ni_route_tables *routing_tables =
counter->counter_dev->routing_tables;
int set_gate_source = 0;
unsigned int gate_source;
int retval = 0;
if (cmd->scan_begin_src == TRIG_EXT) {
set_gate_source = 1;
gate_source = cmd->scan_begin_arg;
} else if (cmd->convert_src == TRIG_EXT) {
set_gate_source = 1;
gate_source = cmd->convert_arg;
}
if (set_gate_source) {
if (CR_CHAN(gate_source) >= NI_NAMES_BASE) {
/* Lookup and use the real register values */
int reg = ni_get_reg_value(CR_CHAN(gate_source),
NI_CtrGate(cidx),
routing_tables);
if (reg < 0)
return -EINVAL;
retval = ni_tio_set_gate_src_raw(counter, 0, reg);
} else {
/*
* This function must be used separately since it does
* not expect real register values and attempts to
* convert these to real register values.
*/
retval = ni_tio_set_gate_src(counter, 0, gate_source);
}
}
if (cmd->flags & CMDF_WAKE_EOS) {
ni_tio_set_bits(counter, NITIO_INT_ENA_REG(cidx),
GI_GATE_INTERRUPT_ENABLE(cidx),
GI_GATE_INTERRUPT_ENABLE(cidx));
}
return retval;
}
int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct ni_gpct *counter = s->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
int retval = 0;
unsigned long flags;
spin_lock_irqsave(&counter->lock, flags);
if (!counter->mite_chan) {
dev_err(counter->counter_dev->dev->class_dev,
"commands only supported with DMA. ");
dev_err(counter->counter_dev->dev->class_dev,
"Interrupt-driven commands not yet implemented.\n");
retval = -EIO;
} else {
retval = ni_tio_cmd_setup(s);
if (retval == 0) {
if (cmd->flags & CMDF_WRITE)
retval = ni_tio_output_cmd(s);
Annotation
- Immediate include surface: `linux/module.h`, `ni_tio_internal.h`, `mite.h`, `ni_routes.h`.
- Detected declarations: `function Copyright`, `function ni_tio_input_inttrig`, `function ni_tio_input_cmd`, `function ni_tio_output_cmd`, `function ni_tio_cmd_setup`, `function ni_tio_cmd`, `function ni_tio_cmdtest`, `function ni_tio_cancel`, `function should_ack_gate`, `function ni_tio_acknowledge_and_confirm`.
- 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.
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.