[PATCH 6/9] staging: comedi: ni_usb6501: add ni6501_cnt_insn_config()

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

 



Add function for counter subdevice configuration.

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

diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c
index cef93d2..4e5afac 100644
--- a/drivers/staging/comedi/drivers/ni_usb6501.c
+++ b/drivers/staging/comedi/drivers/ni_usb6501.c
@@ -439,6 +439,34 @@ static int ni6501_dio_insn_bits(struct comedi_device *dev,
 	return insn->n;
 }
 
+static int ni6501_cnt_insn_config(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn,
+				  unsigned int *data)
+{
+	int ret;
+	u32 counter = 0;
+
+	switch (data[0]) {
+	case INSN_CONFIG_ARM:
+		ret = ni6501_counter_command(dev, START_COUNTER, NULL);
+		break;
+	case INSN_CONFIG_DISARM:
+		ret = ni6501_counter_command(dev, STOP_COUNTER, NULL);
+		break;
+	case INSN_CONFIG_RESET:
+		ret = ni6501_counter_command(dev, STOP_COUNTER, NULL);
+		if (ret)
+			break;
+		ret = ni6501_counter_command(dev, WRITE_COUNTER, &counter);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return ret;
+}
+
 static int ni6501_alloc_usb_buffers(struct comedi_device *dev)
 {
 	struct ni6501_private *devpriv = dev->private;
-- 
1.7.10.4

_______________________________________________
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