Re: [PATCH 11/21] staging: comedi: pcmuio: simplify 'n_subdevs' and 's->n_chan'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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 <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
  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: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux