staging: comedi: amplc_dio200_common: fix the cmd->start_arg use
This driver supports two cmd->start_src values, TRIG_NOW and TRIG_INT. TRIG_NOW sources should always have an arg of 0. For TRIG_INT sources, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. This driver trivially validates the arg for both sources to be 0. Refactor the (*inttrig) so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, refactor the (*do_cmd) to use if/else instead of the switch when handling the cmd->start_src. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
01dc2a05f4
commit
ebe0f68edd
@ -281,22 +281,18 @@ static int dio200_start_intr(struct comedi_device *dev,
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
|
||||
*/
|
||||
static int
|
||||
dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
|
||||
unsigned int trignum)
|
||||
static int dio200_inttrig_start_intr(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
unsigned int trig_num)
|
||||
{
|
||||
struct dio200_subdev_intr *subpriv;
|
||||
struct dio200_subdev_intr *subpriv = s->private;
|
||||
struct comedi_cmd *cmd = &s->async->cmd;
|
||||
unsigned long flags;
|
||||
int event = 0;
|
||||
|
||||
if (trignum != 0)
|
||||
if (trig_num != cmd->start_arg)
|
||||
return -EINVAL;
|
||||
|
||||
subpriv = s->private;
|
||||
|
||||
spin_lock_irqsave(&subpriv->spinlock, flags);
|
||||
s->async->inttrig = NULL;
|
||||
if (subpriv->active)
|
||||
@ -528,16 +524,11 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set up start of acquisition. */
|
||||
switch (cmd->start_src) {
|
||||
case TRIG_INT:
|
||||
if (cmd->start_src == TRIG_INT)
|
||||
s->async->inttrig = dio200_inttrig_start_intr;
|
||||
break;
|
||||
default:
|
||||
/* TRIG_NOW */
|
||||
else /* TRIG_NOW */
|
||||
event = dio200_start_intr(dev, s);
|
||||
break;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&subpriv->spinlock, flags);
|
||||
|
||||
if (event)
|
||||
|
Loading…
Reference in New Issue
Block a user