On 2014-09-16 12:40, Luca Ellero wrote:
Add function for writing to counter subdevice.
Signed-off-by: Luca Ellero <luca.ellero@xxxxxxxxxxxxxxxx>
---
drivers/staging/comedi/drivers/ni_usb6501.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c
index ba2058b..791058d 100644
--- a/drivers/staging/comedi/drivers/ni_usb6501.c
+++ b/drivers/staging/comedi/drivers/ni_usb6501.c
@@ -484,6 +484,20 @@ static int ni6501_cnt_insn_read(struct comedi_device *dev,
return insn->n;
}
+static int ni6501_cnt_insn_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ int ret;
+
+ ret = ni6501_counter_command(dev, WRITE_COUNTER, data);
+ if (ret)
+ return ret;
+
+ return insn->n;
+}
+
insn_write ought to be able to handle an array of more than one data
value. If it doesn't make much sense to write more than one data value
to the counter, you could write just the final one, like this:
if (insn->n) {
u32 counter = data[insn->n - 1];
ret = ni6501_counter_command(dev, WRITE_COUNTER,
&counter);
if (ret)
return ret;
}
return insn->n;
Or you could use a 'for' loop to write all the data values if you think
it's worth it!
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@xxxxxxxxx> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel