aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/vmk80xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/comedi/drivers/vmk80xx.c')
-rw-r--r--drivers/staging/comedi/drivers/vmk80xx.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index a19a56ee0eef..e37118321a27 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -18,21 +18,22 @@
GNU General Public License for more details.
*/
/*
-Driver: vmk80xx
-Description: Velleman USB Board Low-Level Driver
-Devices: K8055/K8061 aka VM110/VM140
-Author: Manuel Gebele <forensixs@gmx.de>
-Updated: Sun, 10 May 2009 11:14:59 +0200
-Status: works
-
-Supports:
- - analog input
- - analog output
- - digital input
- - digital output
- - counter
- - pwm
-*/
+ * Driver: vmk80xx
+ * Description: Velleman USB Board Low-Level Driver
+ * Devices: [Velleman] K8055 (K8055/VM110), K8061 (K8061/VM140),
+ * VM110 (K8055/VM110), VM140 (K8061/VM140)
+ * Author: Manuel Gebele <forensixs@gmx.de>
+ * Updated: Sun, 10 May 2009 11:14:59 +0200
+ * Status: works
+ *
+ * Supports:
+ * - analog input
+ * - analog output
+ * - digital input
+ * - digital output
+ * - counter
+ * - pwm
+ */
#include <linux/kernel.h>
#include <linux/module.h>
@@ -41,10 +42,9 @@ Supports:
#include <linux/input.h>
#include <linux/slab.h>
#include <linux/poll.h>
-#include <linux/usb.h>
#include <linux/uaccess.h>
-#include "../comedidev.h"
+#include "../comedi_usb.h"
enum {
DEVICE_VMK8055,
@@ -550,41 +550,35 @@ static int vmk80xx_cnt_insn_config(struct comedi_device *dev,
unsigned int *data)
{
struct vmk80xx_private *devpriv = dev->private;
- unsigned int insn_cmd;
- int chan;
+ unsigned int chan = CR_CHAN(insn->chanspec);
int cmd;
int reg;
- int n;
-
- insn_cmd = data[0];
- if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET)
- return -EINVAL;
+ int ret;
down(&devpriv->limit_sem);
-
- chan = CR_CHAN(insn->chanspec);
-
- if (devpriv->model == VMK8055_MODEL) {
- if (!chan) {
- cmd = VMK8055_CMD_RST_CNT1;
- reg = VMK8055_CNT1_REG;
+ switch (data[0]) {
+ case INSN_CONFIG_RESET:
+ if (devpriv->model == VMK8055_MODEL) {
+ if (!chan) {
+ cmd = VMK8055_CMD_RST_CNT1;
+ reg = VMK8055_CNT1_REG;
+ } else {
+ cmd = VMK8055_CMD_RST_CNT2;
+ reg = VMK8055_CNT2_REG;
+ }
+ devpriv->usb_tx_buf[reg] = 0x00;
} else {
- cmd = VMK8055_CMD_RST_CNT2;
- reg = VMK8055_CNT2_REG;
+ cmd = VMK8061_CMD_RST_CNT;
}
-
- devpriv->usb_tx_buf[reg] = 0x00;
- } else {
- cmd = VMK8061_CMD_RST_CNT;
+ ret = vmk80xx_write_packet(dev, cmd);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
}
-
- for (n = 0; n < insn->n; n++)
- if (vmk80xx_write_packet(dev, cmd))
- break;
-
up(&devpriv->limit_sem);
- return n;
+ return ret ? ret : insn->n;
}
static int vmk80xx_cnt_insn_write(struct comedi_device *dev,