diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-06-18 16:23:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-24 18:51:02 -0400 |
commit | c87e1f26054388b661298a61e906a03fa2cd193e (patch) | |
tree | a442c7b51c721479d5c19460b2709907de5a4d3e | |
parent | d4fd9a5861b2349855e02d403b108dc98cdda022 (diff) |
staging: comedi: pcmuio: simplify 'n_subdevs' and 's->n_chan'
The number of subdevices needed by the driver is based on the
'num_asics' reported by the boardinfo and each subdevice always
has 24 channels. Simplify the attach a bit.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/pcmuio.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 85a64807a073..e21594bde226 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c | |||
@@ -658,7 +658,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
658 | struct comedi_subdevice *s; | 658 | struct comedi_subdevice *s; |
659 | struct pcmuio_private *devpriv; | 659 | struct pcmuio_private *devpriv; |
660 | struct pcmuio_subdev_private *subpriv; | 660 | struct pcmuio_subdev_private *subpriv; |
661 | int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0; | 661 | int sdev_no, n_subdevs, port, asic, thisasic_chanct = 0; |
662 | unsigned int irq[MAX_ASICS]; | 662 | unsigned int irq[MAX_ASICS]; |
663 | int ret; | 663 | int ret; |
664 | 664 | ||
@@ -680,9 +680,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
680 | spin_lock_init(&devpriv->asics[asic].spinlock); | 680 | spin_lock_init(&devpriv->asics[asic].spinlock); |
681 | } | 681 | } |
682 | 682 | ||
683 | chans_left = CHANS_PER_ASIC * board->num_asics; | 683 | n_subdevs = board->num_asics * 2; |
684 | n_subdevs = (chans_left / MAX_CHANS_PER_SUBDEV) + | ||
685 | (!!(chans_left % MAX_CHANS_PER_SUBDEV)); | ||
686 | devpriv->sprivs = kcalloc(n_subdevs, | 684 | devpriv->sprivs = kcalloc(n_subdevs, |
687 | sizeof(struct pcmuio_subdev_private), | 685 | sizeof(struct pcmuio_subdev_private), |
688 | GFP_KERNEL); | 686 | GFP_KERNEL); |
@@ -707,7 +705,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
707 | s->type = COMEDI_SUBD_DIO; | 705 | s->type = COMEDI_SUBD_DIO; |
708 | s->insn_bits = pcmuio_dio_insn_bits; | 706 | s->insn_bits = pcmuio_dio_insn_bits; |
709 | s->insn_config = pcmuio_dio_insn_config; | 707 | s->insn_config = pcmuio_dio_insn_config; |
710 | s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV); | 708 | s->n_chan = 24; |
711 | subpriv->intr.asic = -1; | 709 | subpriv->intr.asic = -1; |
712 | s->len_chanlist = 1; | 710 | s->len_chanlist = 1; |
713 | 711 | ||
@@ -738,15 +736,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) | |||
738 | thisasic_chanct += CHANS_PER_PORT; | 736 | thisasic_chanct += CHANS_PER_PORT; |
739 | } | 737 | } |
740 | spin_lock_init(&subpriv->intr.spinlock); | 738 | spin_lock_init(&subpriv->intr.spinlock); |
741 | |||
742 | chans_left -= s->n_chan; | ||
743 | |||
744 | if (!chans_left) { | ||
745 | /* reset to our first asic, to do intr subdevs */ | ||
746 | asic = 0; | ||
747 | port = 0; | ||
748 | } | ||
749 | |||
750 | } | 739 | } |
751 | 740 | ||
752 | init_asics(dev); /* clear out all the registers, basically */ | 741 | init_asics(dev); /* clear out all the registers, basically */ |