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