From ebe0f68eddc2e351b3b8b865f478592f231baaea Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:53 -0700 Subject: [PATCH] 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/amplc_dio200_common.c | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 818a0d7e3d58..4ac320884ac6 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -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) -- 2.20.1