Commit 790b2f06 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: cb_pcidas: tidy up analog input subdevice init

For aesthetics, add some whitespace to the subdevice initialization
and rename the subdevice functions to follow the normal form in
comedi drivers.

Async command support uses interrupts. For clarity, make sure the
driver has an IRQ before initializing command support.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c5c51b1d
...@@ -332,9 +332,10 @@ static int cb_pcidas_ai_eoc(struct comedi_device *dev, ...@@ -332,9 +332,10 @@ static int cb_pcidas_ai_eoc(struct comedi_device *dev,
return -EBUSY; return -EBUSY;
} }
static int cb_pcidas_ai_rinsn(struct comedi_device *dev, static int cb_pcidas_ai_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 cb_pcidas_private *devpriv = dev->private; struct cb_pcidas_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
...@@ -384,8 +385,10 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev, ...@@ -384,8 +385,10 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
return n; return n;
} }
static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, static int cb_pcidas_ai_insn_config(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
struct cb_pcidas_private *devpriv = dev->private; struct cb_pcidas_private *devpriv = dev->private;
int id = data[0]; int id = data[0];
...@@ -960,9 +963,8 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, ...@@ -960,9 +963,8 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
return 0; return 0;
} }
/* cancel analog input command */ static int cb_pcidas_ai_cancel(struct comedi_device *dev,
static int cb_pcidas_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
struct comedi_subdevice *s)
{ {
struct cb_pcidas_private *devpriv = dev->private; struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags; unsigned long flags;
...@@ -1303,22 +1305,24 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, ...@@ -1303,22 +1305,24 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
if (ret) if (ret)
return ret; return ret;
/* Analog Input subdevice */
s = &dev->subdevices[0]; s = &dev->subdevices[0];
/* analog input subdevice */ s->type = COMEDI_SUBD_AI;
dev->read_subdev = s; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
s->type = COMEDI_SUBD_AI; s->n_chan = 16;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ; s->maxdata = board->is_16bit ? 0xffff : 0x0fff;
/* WARNING: Number of inputs in differential mode is ignored */
s->n_chan = 16;
s->len_chanlist = s->n_chan;
s->maxdata = board->is_16bit ? 0xffff : 0x0fff;
s->range_table = board->use_alt_range ? &cb_pcidas_alt_ranges s->range_table = board->use_alt_range ? &cb_pcidas_alt_ranges
: &cb_pcidas_ranges; : &cb_pcidas_ranges;
s->insn_read = cb_pcidas_ai_rinsn; s->insn_read = cb_pcidas_ai_insn_read;
s->insn_config = ai_config_insn; s->insn_config = cb_pcidas_ai_insn_config;
s->do_cmd = cb_pcidas_ai_cmd; if (dev->irq) {
s->do_cmdtest = cb_pcidas_ai_cmdtest; dev->read_subdev = s;
s->cancel = cb_pcidas_cancel; s->subdev_flags |= SDF_CMD_READ;
s->len_chanlist = s->n_chan;
s->do_cmd = cb_pcidas_ai_cmd;
s->do_cmdtest = cb_pcidas_ai_cmdtest;
s->cancel = cb_pcidas_ai_cancel;
}
/* Analog Output subdevice */ /* Analog Output subdevice */
s = &dev->subdevices[1]; s = &dev->subdevices[1];
......
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