提交 fc5ba1bd 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

staging: comedi: pcmuio: tidy up pcmuio_attach()

Clean up the local variables, 'sdev_no' and 'asic' are both used in
simple for () loops. Use the local variable 'i' for both cases. The
'n_subdevs' variable is only used in one place, just remove it.

For aesthetics, add some whitespace to the subdevice init and reorder
it to follow the more typical style in comedi drivers.

Remove the unnecessary init of s->len_chanlist for subdevices that do
not support async commands (interrupts). The core will default it to
the correct value.
Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 fbd66a7e
......@@ -591,8 +591,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
const struct pcmuio_board *board = comedi_board(dev);
struct comedi_subdevice *s;
struct pcmuio_private *devpriv;
int sdev_no, n_subdevs, asic;
int ret;
int i;
ret = comedi_request_region(dev, it->options[0],
board->num_asics * PCMUIO_ASIC_IOSIZE);
......@@ -603,8 +603,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!devpriv)
return -ENOMEM;
for (asic = 0; asic < PCMUIO_MAX_ASICS; ++asic) {
struct pcmuio_asic *chip = &devpriv->asics[asic];
for (i = 0; i < PCMUIO_MAX_ASICS; ++i) {
struct pcmuio_asic *chip = &devpriv->asics[i];
spin_lock_init(&chip->pagelock);
spin_lock_init(&chip->spinlock);
......@@ -633,34 +633,29 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
}
n_subdevs = board->num_asics * 2;
ret = comedi_alloc_subdevices(dev, n_subdevs);
ret = comedi_alloc_subdevices(dev, board->num_asics * 2);
if (ret)
return ret;
for (sdev_no = 0; sdev_no < (int)dev->n_subdevices; ++sdev_no) {
s = &dev->subdevices[sdev_no];
s->maxdata = 1;
s->range_table = &range_digital;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->type = COMEDI_SUBD_DIO;
s->insn_bits = pcmuio_dio_insn_bits;
s->insn_config = pcmuio_dio_insn_config;
s->n_chan = 24;
for (i = 0; i < dev->n_subdevices; ++i) {
s = &dev->subdevices[i];
s->type = COMEDI_SUBD_DIO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 24;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = pcmuio_dio_insn_bits;
s->insn_config = pcmuio_dio_insn_config;
/* subdevices 0 and 2 can suppport interrupts */
if ((sdev_no == 0 && dev->irq) ||
(sdev_no == 2 && devpriv->irq2)) {
if ((i == 0 && dev->irq) || (i == 2 && devpriv->irq2)) {
/* setup the interrupt subdevice */
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->cancel = pcmuio_cancel;
s->do_cmd = pcmuio_cmd;
s->do_cmdtest = pcmuio_cmdtest;
s->len_chanlist = s->n_chan;
} else {
s->len_chanlist = 1;
s->subdev_flags |= SDF_CMD_READ;
s->len_chanlist = s->n_chan;
s->cancel = pcmuio_cancel;
s->do_cmd = pcmuio_cmd;
s->do_cmdtest = pcmuio_cmdtest;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册