Re: [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]

 



On 22/10/14 23:37, H Hartley Sweeten wrote:
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.

In general, the scan data could be packed into more than one "sample", but you can fit 8*bytes_per_sample() 1-bit samples in each "sample". In practice, currently only the ni_pcidio driver sets the SDF_PACKED flag (although some other drivers ought to set it) and the whole scan will fit into a single "sample" in that case.

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);


Is this patch even necessary? comedi_bytes_per_scan() assumes digital samples will be packed into a whole number of "samples" and calculates the scan length in bytes accordingly.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
_______________________________________________
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