From 90a35c15c5d7d5c6254772d2752975dda185710c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Dec 2012 17:27:02 -0700 Subject: staging: comedi: store the 'index' for each subdevice Store the 'index' for each comedi_subdevice when they are initially allocated by comedi_alloc_subdevice(). This allows removing the pointer math in comedi_fops.c which is used to figure out the index that user space uses to access the individual subdevices. Fix the ni_mio_common driver so it also uses the 'index' instead of doing the pointer math. Also, remove a couple unused macros in the pcmda12, pcmmio, and pcmuio drivers which also do the pointer math to figure out the index. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/comedi/comedi_fops.c') diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index dda47b161bcf..2fd577fa941e 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -169,7 +169,7 @@ static int resize_async_buffer(struct comedi_device *dev, } DPRINTK("comedi%i subd %d buffer resized to %i bytes\n", - dev->minor, (int)(s - dev->subdevices), async->prealloc_bufsz); + dev->minor, s->index, async->prealloc_bufsz); return 0; } @@ -624,13 +624,13 @@ static int do_devinfo_ioctl(struct comedi_device *dev, s = comedi_read_subdevice(info); if (s) - devinfo.read_subdevice = s - dev->subdevices; + devinfo.read_subdevice = s->index; else devinfo.read_subdevice = -1; s = comedi_write_subdevice(info); if (s) - devinfo.write_subdevice = s - dev->subdevices; + devinfo.write_subdevice = s->index; else devinfo.write_subdevice = -1; @@ -2398,7 +2398,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev, s->minor = i; csdev = device_create(comedi_class, dev->class_dev, MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i_subd%i", - dev->minor, (int)(s - dev->subdevices)); + dev->minor, s->index); if (!IS_ERR(csdev)) s->class_dev = csdev; dev_set_drvdata(csdev, info); -- cgit v1.2.3-55-g7522