[PATCH 11/13] staging: comedi: adv_pci1724: return insn->n

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

 



Follow the usual behaviour for comedi read and write instructions of
returning the number of data values read or written.  When reading back
written values, read back the number of values specified by `insn->n`
instead of reading back a single value.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Frank Mori Hess <fmh6jj@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/adv_pci1724.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c
index 4649a29..af64d59 100644
--- a/drivers/staging/comedi/drivers/adv_pci1724.c
+++ b/drivers/staging/comedi/drivers/adv_pci1724.c
@@ -327,7 +327,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 			return retval;
 		devpriv->ao_value[channel] = data[i];
 	}
-	return 1;
+	return insn->n;
 }
 
 static int ao_readback_insn(struct comedi_device *dev,
@@ -336,15 +336,17 @@ static int ao_readback_insn(struct comedi_device *dev,
 {
 	struct adv_pci1724_private *devpriv = dev->private;
 	int channel = CR_CHAN(insn->chanspec);
+	int i;
 
 	if (devpriv->ao_value[channel] < 0) {
 		comedi_error(dev,
 			     "Cannot read back channels which have not yet been written to.");
 		return -EIO;
 	}
-	data[0] = devpriv->ao_value[channel];
+	for (i = 0; i < insn->n; i++)
+		data[i] = devpriv->ao_value[channel];
 
-	return 1;
+	return insn->n;
 }
 
 static int offset_write_insn(struct comedi_device *dev,
@@ -366,7 +368,7 @@ static int offset_write_insn(struct comedi_device *dev,
 		devpriv->offset_value[channel] = data[i];
 	}
 
-	return 1;
+	return insn->n;
 }
 
 static int offset_read_insn(struct comedi_device *dev,
@@ -375,15 +377,17 @@ static int offset_read_insn(struct comedi_device *dev,
 {
 	struct adv_pci1724_private *devpriv = dev->private;
 	unsigned int channel = CR_CHAN(insn->chanspec);
+	int i;
 
 	if (devpriv->offset_value[channel] < 0) {
 		comedi_error(dev,
 			     "Cannot read back channels which have not yet been written to.");
 		return -EIO;
 	}
-	data[0] = devpriv->offset_value[channel];
+	for (i = 0; i < insn->n; i++)
+		data[i] = devpriv->offset_value[channel];
 
-	return 1;
+	return insn->n;
 }
 
 static int gain_write_insn(struct comedi_device *dev,
@@ -405,7 +409,7 @@ static int gain_write_insn(struct comedi_device *dev,
 		devpriv->gain_value[channel] = data[i];
 	}
 
-	return 1;
+	return insn->n;
 }
 
 static int gain_read_insn(struct comedi_device *dev,
@@ -414,15 +418,17 @@ static int gain_read_insn(struct comedi_device *dev,
 {
 	struct adv_pci1724_private *devpriv = dev->private;
 	unsigned int channel = CR_CHAN(insn->chanspec);
+	int i;
 
 	if (devpriv->gain_value[channel] < 0) {
 		comedi_error(dev,
 			     "Cannot read back channels which have not yet been written to.");
 		return -EIO;
 	}
-	data[0] = devpriv->gain_value[channel];
+	for (i = 0; i < insn->n; i++)
+		data[i] = devpriv->gain_value[channel];
 
-	return 1;
+	return insn->n;
 }
 
 MODULE_AUTHOR("Comedi http://www.comedi.org";);
-- 
1.8.1.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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