This driver supports three cmd->start_src values, TRIG_NOW, TRIG_EXT, and TRIG_INT. TRIG_NOW sources should always have an arg of 0 and arg for TRIG_EXT sources is driver specific. This driver does not use the cmd->start_arg with the TRIG_EXT source so a trivial value of 0 is good. When the cmd->start_src is TRIG_INT the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. This driver allows any value to be used and currently carries that value in the private data. Refactor the (*do_cmdtest) so that the trivial validation of the cmd->start_arg is clear. Refactor the (*inttrig) so that the cmd->start_arg is used directly to check the trig_num and remove the then unused 'ai_inttrig_start' member from the private data. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/adl_pci9118.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 465b304..8f3491a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -411,7 +411,6 @@ struct pci9118_private { */ unsigned int ai_maskerr; /* which warning was printed */ unsigned int ai_maskharderr; /* on which error bits stops */ - unsigned int ai_inttrig_start; /* TRIG_INT for start */ }; static int check_channel_list(struct comedi_device *dev, @@ -1135,11 +1134,13 @@ static irqreturn_t interrupt_pci9118(int irq, void *d) } static int pci9118_ai_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trig_num) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; - if (trignum != devpriv->ai_inttrig_start) + if (trig_num != cmd->start_arg) return -EINVAL; devpriv->ai12_startstop &= ~START_AI_INT; @@ -1221,8 +1222,15 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src & (TRIG_NOW | TRIG_EXT)) + switch (cmd->start_src) { + case TRIG_NOW: + case TRIG_EXT: err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_INT: + /* start_arg is the internal trigger (any value) */ + break; + } if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT)) err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); @@ -1624,7 +1632,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } if (cmd->start_src == TRIG_INT) { devpriv->ai12_startstop |= START_AI_INT; - devpriv->ai_inttrig_start = cmd->start_arg; s->async->inttrig = pci9118_ai_inttrig; } #if 0 -- 1.8.5.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel