[Originally posted 2013-06-19.  Reposting to new driverdev-devel list.]

On 2013-06-18 21:23, H Hartley Sweeten wrote:
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.

We could probably assume all subdevices have the same number of channels (MAX_CHANS_PER_SUBDEV, i.e. 24) and just skip the rounding stuff. MAX_CHANS_PER_SUBDEV is probably better off just being called CHANS_PER_SUBDEV if they all have the same number of channels.

All those calculations in the #defines do my head in. Replacing them with simple integer values would be an improvement!


Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
  drivers/staging/comedi/drivers/pcmuio.c | 17 +++--------------
  1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcmuio.c 
b/drivers/staging/comedi/drivers/pcmuio.c
index 85a6480..e21594b 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)
        struct comedi_subdevice *s;
        struct pcmuio_private *devpriv;
        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];
        int ret;

@@ -680,9 +680,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
                spin_lock_init(&devpriv->asics[asic].spinlock);
        }

-       chans_left = CHANS_PER_ASIC * board->num_asics;
-       n_subdevs = (chans_left / MAX_CHANS_PER_SUBDEV) +
-                   (!!(chans_left % MAX_CHANS_PER_SUBDEV));
+       n_subdevs = board->num_asics * 2;

It's a shame there is no SUBDEVS_PER_ASIC #define as there seems to be a #define for most of the other X_PER_Y values!

        devpriv->sprivs = kcalloc(n_subdevs,
                                  sizeof(struct pcmuio_subdev_private),
                                  GFP_KERNEL);
@@ -707,7 +705,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
                s->type = COMEDI_SUBD_DIO;
                s->insn_bits = pcmuio_dio_insn_bits;
                s->insn_config = pcmuio_dio_insn_config;
-               s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV);
+               s->n_chan = 24;

Could set s->n_chan = MAX_CHANS_PER_SUBDEV here.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to