From: H Hartley Sweeten Date: Thu, 17 Apr 2014 17:07:53 +0000 (-0700) Subject: staging: comedi: amplc_dio200_common: fix the cmd->start_arg use X-Git-Tag: v5.15~17469^2~39^2~1333 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ebe0f68eddc2e351b3b8b865f478592f231baaea;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 818a0d7..4ac3208 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)