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

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: 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 d4fd9a58
...@@ -658,7 +658,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -658,7 +658,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
struct comedi_subdevice *s; struct comedi_subdevice *s;
struct pcmuio_private *devpriv; struct pcmuio_private *devpriv;
struct pcmuio_subdev_private *subpriv; struct pcmuio_subdev_private *subpriv;
int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0; int sdev_no, n_subdevs, port, asic, thisasic_chanct = 0;
unsigned int irq[MAX_ASICS]; unsigned int irq[MAX_ASICS];
int ret; int ret;
...@@ -680,9 +680,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -680,9 +680,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
spin_lock_init(&devpriv->asics[asic].spinlock); spin_lock_init(&devpriv->asics[asic].spinlock);
} }
chans_left = CHANS_PER_ASIC * board->num_asics; n_subdevs = board->num_asics * 2;
n_subdevs = (chans_left / MAX_CHANS_PER_SUBDEV) +
(!!(chans_left % MAX_CHANS_PER_SUBDEV));
devpriv->sprivs = kcalloc(n_subdevs, devpriv->sprivs = kcalloc(n_subdevs,
sizeof(struct pcmuio_subdev_private), sizeof(struct pcmuio_subdev_private),
GFP_KERNEL); GFP_KERNEL);
...@@ -707,7 +705,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -707,7 +705,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->type = COMEDI_SUBD_DIO; s->type = COMEDI_SUBD_DIO;
s->insn_bits = pcmuio_dio_insn_bits; s->insn_bits = pcmuio_dio_insn_bits;
s->insn_config = pcmuio_dio_insn_config; s->insn_config = pcmuio_dio_insn_config;
s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV); s->n_chan = 24;
subpriv->intr.asic = -1; subpriv->intr.asic = -1;
s->len_chanlist = 1; s->len_chanlist = 1;
...@@ -738,15 +736,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -738,15 +736,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
thisasic_chanct += CHANS_PER_PORT; thisasic_chanct += CHANS_PER_PORT;
} }
spin_lock_init(&subpriv->intr.spinlock); spin_lock_init(&subpriv->intr.spinlock);
chans_left -= s->n_chan;
if (!chans_left) {
/* reset to our first asic, to do intr subdevs */
asic = 0;
port = 0;
}
} }
init_asics(dev); /* clear out all the registers, basically */ init_asics(dev); /* clear out all the registers, basically */
......
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