diff options
author | H Hartley Sweeten | 2012-12-20 01:27:02 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2013-01-07 23:28:19 +0100 |
commit | 90a35c15c5d7d5c6254772d2752975dda185710c (patch) | |
tree | 7f240eb4dcd4d9f90e047a75515b7c8d50ca619d /drivers/staging/comedi/comedi_fops.c | |
parent | staging: comedi: comedi_fops: use kzalloc in comedi_alloc_subdevice_minor() (diff) | |
download | kernel-qcow2-linux-90a35c15c5d7d5c6254772d2752975dda185710c.tar.gz kernel-qcow2-linux-90a35c15c5d7d5c6254772d2752975dda185710c.tar.xz kernel-qcow2-linux-90a35c15c5d7d5c6254772d2752975dda185710c.zip |
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 <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 8 |
1 files changed, 4 insertions, 4 deletions
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); |