From: Ian Abbott Date: Thu, 26 Sep 2013 09:16:38 +0000 (+0100) Subject: staging: comedi: pcl711: handle cmd->stop_src and stop_arg X-Git-Tag: firefly_0821_release~176^2~5057^2~565 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2ce4e57b9afea13711606839acd382256d201306;p=firefly-linux-kernel-4.4.55.git staging: comedi: pcl711: handle cmd->stop_src and stop_arg The interrupt handler used to support asynchronous commands on the AI subdevice currently marks the command as finished (setting the "end of acquisition" event flag and returning to software-triggered acquisition mode) once it has decremented `devpriv->ntrig` to 0. However, nothing sets `devpriv->ntrig`, as noted in the "FIXME" comment. If the `stop_src` setting of the asynchronous command is `TRIG_COUNT`, then the `stop_arg` setting indicates the number of scans to be performed in the overall acquisition. (Otherwise, `stop_src` will be `TRIG_NONE`, meaning the acquisition should run indefinitely until cancelled.) When starting the acquisition in `pcl711_ai_cmd()`, set `devpriv->ntrig` to the number of scans to be performed (`stop_arg`) if `stop_src` is `TRIG_COUNT`. In the interrupt handler, don't decrement `devpriv->ntrig` or handle end of acquision unless `stop_src` is `TRIG_COUNT`. Also check for an empty acquisition in `pcl711_ai_cmd()`, i.e. one where `stop_src` is `TRIG_COUNT` and `stop_arg` is zero and just mark end of acquisition without actually setting up the interrupts in this case. Also change the type of the `ntrig` member of the private data structure to `unsigned int` as it should be (same type as `stop_arg`). Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 939a11f4e3c8..daa78fa63be1 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -156,7 +156,7 @@ static const struct pcl711_board boardtypes[] = { }; struct pcl711_private { - int ntrig; + unsigned int ntrig; unsigned int ao_readback[2]; unsigned int divisor1; unsigned int divisor2; @@ -213,10 +213,8 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); - /* FIXME! Nothing else sets ntrig! */ - if (!(--devpriv->ntrig)) { + if (s->async->cmd.stop_src == TRIG_COUNT && !(--devpriv->ntrig)) { pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG); - s->async->events |= COMEDI_CB_EOA; } comedi_event(dev, s); @@ -367,6 +365,16 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) pcl711_set_changain(dev, s, cmd->chanlist[0]); + if (cmd->stop_src == TRIG_COUNT) { + if (cmd->stop_arg == 0) { + /* an empty acquisition */ + s->async->events |= COMEDI_CB_EOA; + comedi_event(dev, s); + return 0; + } + devpriv->ntrig = cmd->stop_arg; + } + if (cmd->scan_begin_src == TRIG_TIMER) { i8254_load(dev->iobase + PCL711_TIMER_BASE, 0, 1, devpriv->divisor1, I8254_MODE2 | I8254_BINARY);