Commit 75a45d92 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: vmk80xx: cleanup counter subdevice init

Change the 'cnt_bits' in the boardinfo to 'cnt_maxdata' so that the
calculation of s->maxdata can be removed. Also, change the type to
match the comedi_subdevice type. Add a comment about the '0' value
for DEVICE_VMK8061.

The s->maxdata should always be set for the subdevice. Move it out
of the conditional.

Rename the (*insn_read), (*insn_config_, and (*insn_write) functions
for the counter subdevice to make grepping easier.

For aesthetic reasons, add some whitespace to the subdevice init.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b639e096
...@@ -163,7 +163,7 @@ struct vmk80xx_board { ...@@ -163,7 +163,7 @@ struct vmk80xx_board {
unsigned int ai_maxdata; unsigned int ai_maxdata;
int ao_nchans; int ao_nchans;
int di_nchans; int di_nchans;
__le16 cnt_bits; unsigned int cnt_maxdata;
__u8 pwm_chans; __u8 pwm_chans;
__le16 pwm_bits; __le16 pwm_bits;
}; };
...@@ -177,7 +177,7 @@ static const struct vmk80xx_board vmk80xx_boardinfo[] = { ...@@ -177,7 +177,7 @@ static const struct vmk80xx_board vmk80xx_boardinfo[] = {
.ai_maxdata = 0x00ff, .ai_maxdata = 0x00ff,
.ao_nchans = 2, .ao_nchans = 2,
.di_nchans = 6, .di_nchans = 6,
.cnt_bits = 16, .cnt_maxdata = 0xffff,
.pwm_chans = 0, .pwm_chans = 0,
.pwm_bits = 0, .pwm_bits = 0,
}, },
...@@ -189,7 +189,7 @@ static const struct vmk80xx_board vmk80xx_boardinfo[] = { ...@@ -189,7 +189,7 @@ static const struct vmk80xx_board vmk80xx_boardinfo[] = {
.ai_maxdata = 0x03ff, .ai_maxdata = 0x03ff,
.ao_nchans = 8, .ao_nchans = 8,
.di_nchans = 8, .di_nchans = 8,
.cnt_bits = 0, .cnt_maxdata = 0, /* unknown, device is not writeable */
.pwm_chans = 1, .pwm_chans = 1,
.pwm_bits = 10, .pwm_bits = 10,
}, },
...@@ -900,9 +900,10 @@ static int vmk80xx_do_insn_bits(struct comedi_device *dev, ...@@ -900,9 +900,10 @@ static int vmk80xx_do_insn_bits(struct comedi_device *dev,
return retval; return retval;
} }
static int vmk80xx_cnt_rinsn(struct comedi_device *dev, static int vmk80xx_cnt_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
int chan; int chan;
...@@ -947,9 +948,10 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev, ...@@ -947,9 +948,10 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *dev,
return n; return n;
} }
static int vmk80xx_cnt_cinsn(struct comedi_device *dev, static int vmk80xx_cnt_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
unsigned int insn_cmd; unsigned int insn_cmd;
...@@ -993,9 +995,10 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev, ...@@ -993,9 +995,10 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *dev,
return n; return n;
} }
static int vmk80xx_cnt_winsn(struct comedi_device *dev, static int vmk80xx_cnt_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn,
unsigned int *data)
{ {
struct vmk80xx_private *devpriv = dev->private; struct vmk80xx_private *devpriv = dev->private;
unsigned long debtime; unsigned long debtime;
...@@ -1251,12 +1254,12 @@ static int vmk80xx_attach_common(struct comedi_device *dev) ...@@ -1251,12 +1254,12 @@ static int vmk80xx_attach_common(struct comedi_device *dev)
s->type = COMEDI_SUBD_COUNTER; s->type = COMEDI_SUBD_COUNTER;
s->subdev_flags = SDF_READABLE; s->subdev_flags = SDF_READABLE;
s->n_chan = 2; s->n_chan = 2;
s->insn_read = vmk80xx_cnt_rinsn; s->maxdata = boardinfo->cnt_maxdata;
s->insn_config = vmk80xx_cnt_cinsn; s->insn_read = vmk80xx_cnt_insn_read;
s->insn_config = vmk80xx_cnt_insn_config;
if (devpriv->model == VMK8055_MODEL) { if (devpriv->model == VMK8055_MODEL) {
s->subdev_flags |= SDF_WRITEABLE; s->subdev_flags |= SDF_WRITEABLE;
s->maxdata = (1 << boardinfo->cnt_bits) - 1; s->insn_write = vmk80xx_cnt_insn_write;
s->insn_write = vmk80xx_cnt_winsn;
} }
/* PWM subdevice */ /* PWM subdevice */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment