[PATCH 46/55] staging: comedi: drivers: handle SDF_PACKED in comedi_inc_scan_progress()

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

 



Subdevices that set the SDF_PACKED flag return all the scan data in a single
sample. The cmd->chanlist_len is used to pass the DIO channel information to
the command and does not indicate the length (cmd->scan_end_arg) of the scan.

Currently this flag is not handled in the comedi core files. Modify
comedi_inc_scan_progress() to automatically set the COMEDI_CB_EOS event if
the SDF_PACKED flag is set. This makes the flag work and we can remove the
events from the drivers.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ff2df85..dd8f5db 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -341,12 +341,23 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s,
 			      unsigned int num_bytes)
 {
 	struct comedi_async *async = s->async;
-	unsigned int scan_length = comedi_bytes_per_scan(s);
 
-	async->scan_progress += num_bytes;
-	if (async->scan_progress >= scan_length) {
-		async->scan_progress %= scan_length;
+	/*
+	 * The SDF_PACKED flag indicates that the subdevice does "packed DIO".
+	 *
+	 * This means that all the scan data is returned in a single sample
+	 * and an "end of scan" occurs for every sample.
+	 */
+	if (s->subdev_flags & SDF_PACKED) {
 		async->events |= COMEDI_CB_EOS;
+	} else {
+		unsigned int scan_length = comedi_bytes_per_scan(s);
+
+		async->scan_progress += num_bytes;
+		if (async->scan_progress >= scan_length) {
+			async->scan_progress %= scan_length;
+			async->events |= COMEDI_CB_EOS;
+		}
 	}
 }
 EXPORT_SYMBOL_GPL(comedi_inc_scan_progress);
-- 
2.0.3

_______________________________________________
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