diff options
author | H Hartley Sweeten | 2012-06-12 20:59:55 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2012-06-12 23:44:04 +0200 |
commit | 03afcf472785a63d720202d28d51852d965a95d9 (patch) | |
tree | 738ae55c58b03a51749756ad0596b0666891b691 /drivers/staging/comedi/drivers.c | |
parent | staging: comedi: propogate error code from comedi_alloc_subdevices (diff) | |
download | kernel-qcow2-linux-03afcf472785a63d720202d28d51852d965a95d9.tar.gz kernel-qcow2-linux-03afcf472785a63d720202d28d51852d965a95d9.tar.xz kernel-qcow2-linux-03afcf472785a63d720202d28d51852d965a95d9.zip |
staging: comedi: cleanup comedi_alloc_subdevices
Access the individual comedi_subdevices using a pointer instead
of directly accessing as an array. This is how the rest of the
comedi core accesses them.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r-- | drivers/staging/comedi/drivers.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index ecad2288c9fb..6af4a5b302df 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -58,21 +58,24 @@ struct comedi_driver *comedi_drivers; int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) { + struct comedi_subdevice *s; int i; if (num_subdevices < 1) return -EINVAL; - dev->subdevices = - kcalloc(num_subdevices, sizeof(struct comedi_subdevice), - GFP_KERNEL); - if (!dev->subdevices) + + s = kcalloc(num_subdevices, sizeof(*s), GFP_KERNEL); + if (!s) return -ENOMEM; + dev->subdevices = s; dev->n_subdevices = num_subdevices; + for (i = 0; i < num_subdevices; ++i) { - dev->subdevices[i].device = dev; - dev->subdevices[i].async_dma_dir = DMA_NONE; - spin_lock_init(&dev->subdevices[i].spin_lock); - dev->subdevices[i].minor = -1; + s = dev->subdevices + i; + s->device = dev; + s->async_dma_dir = DMA_NONE; + spin_lock_init(&s->spin_lock); + s->minor = -1; } return 0; } |