Re: [PATCH v2 7/9] staging: comedi: ni_usb6501: add ni6501_cnt_insn_read()

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

 



On 2014-09-16 12:40, Luca Ellero wrote:
Add function for reading from counter subdevice.

Signed-off-by: Luca Ellero <luca.ellero@xxxxxxxxxxxxxxxx>
---
  drivers/staging/comedi/drivers/ni_usb6501.c |   17 +++++++++++++++++
  1 file changed, 17 insertions(+)

diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c
index 31a798e..ba2058b 100644
--- a/drivers/staging/comedi/drivers/ni_usb6501.c
+++ b/drivers/staging/comedi/drivers/ni_usb6501.c
@@ -467,6 +467,23 @@ static int ni6501_cnt_insn_config(struct comedi_device *dev,
  	return ret;
  }

+static int ni6501_cnt_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn,
+				unsigned int *data)
+{
+	int ret;
+	u32 counter;
+
+	ret = ni6501_counter_command(dev, READ_COUNTER, &counter);
+	if (ret)
+		return ret;
+
+	data[0] = counter;
+
+	return insn->n;
+}
+

Generally, insn_read should read insn->n values, like this:

	unsigned int i;

	for (i = 0; i < insn->n; i++) {
		ret = ni_6501_counter_command(dev, READ_COUNTER,
					      &counter);
		if (ret)
			return ret;
		data[i] = counter;
	}

	return insn->n;

--
-=( 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




[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