Commit 47825a9b authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: pcl726: tidy up pcl726_attach()

For aesthetics, add some whitespace to the subdevice initialization.

Only allocate, and initialize, the digital input and output subdevices
if the boardinfo indicates that they exist on the board.
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 716343c4
......@@ -253,12 +253,14 @@ static int pcl726_do_insn_bits(struct comedi_device *dev,
return insn->n;
}
static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
static int pcl726_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
const struct pcl726_board *board = comedi_board(dev);
struct pcl726_private *devpriv;
struct comedi_subdevice *s;
int ret, i;
int ret;
int i;
ret = comedi_request_region(dev, it->options[0], board->io_range);
if (ret)
......@@ -291,47 +293,38 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->rangelist[i] = &range_unknown;
}
ret = comedi_alloc_subdevices(dev, 3);
ret = comedi_alloc_subdevices(dev, board->have_dio ? 3 : 1);
if (ret)
return ret;
/* Analog Output subdevice */
s = &dev->subdevices[0];
/* ao */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
s->n_chan = board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->insn_write = pcl726_ao_insn_write;
s->insn_read = pcl726_ao_insn_read;
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
s->n_chan = board->n_aochan;
s->maxdata = 0x0fff;
s->range_table_list = devpriv->rangelist;
s = &dev->subdevices[1];
/* di */
if (!board->have_dio) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = 16;
s->maxdata = 1;
s->len_chanlist = 1;
s->insn_bits = pcl726_di_insn_bits;
s->range_table = &range_digital;
}
s = &dev->subdevices[2];
/* do */
if (!board->have_dio) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
s->n_chan = 16;
s->maxdata = 1;
s->len_chanlist = 1;
s->insn_bits = pcl726_do_insn_bits;
s->range_table = &range_digital;
s->insn_write = pcl726_ao_insn_write;
s->insn_read = pcl726_ao_insn_read;
if (board->have_dio) {
/* Digital Input subdevice */
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = 16;
s->maxdata = 1;
s->insn_bits = pcl726_di_insn_bits;
s->range_table = &range_digital;
/* Digital Output subdevice */
s = &dev->subdevices[2];
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->insn_bits = pcl726_do_insn_bits;
s->range_table = &range_digital;
}
return 0;
......
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