[PATCH 3/3] staging: comedi: pcl711: put acquired data in buffer for AI command

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

 



The asynchronous command support for the AI subdevice is still missing
one crucial element, it doesn't actually put the acquired data in the
buffer so it can be read()!  Call `comedi_buf_put()` from the interrupt
handler to perform this function.  A return value of 0 from
`comedi_buf_put()` means there was no room in the buffer so set the
`COMEDI_CB_OVERFLOW` and `COMEDI_CB_ERROR` event flags in that case.
Otherwise, set the `COMEDI_CB_BLOCK` and `COMEDI_CB_EOS` event flags to
mark the end of a "scan" (the scan length is currently fixed at one
sample in this driver).

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/pcl711.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index daa78fa..e170f8a 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -213,9 +213,15 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
 
 	outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
 
-	if (s->async->cmd.stop_src == TRIG_COUNT && !(--devpriv->ntrig)) {
-		pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG);
-		s->async->events |= COMEDI_CB_EOA;
+	if (comedi_buf_put(s->async, (short)data) == 0) {
+		s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+	} else {
+		s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+		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);
 	return IRQ_HANDLED;
-- 
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