[PATCH 2/3] staging: comedi: pcl711: handle cmd->stop_src and stop_arg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/pcl711.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index 939a11f..daa78fa 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);
-- 
1.8.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux