Commit 03afcf47 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbott@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8b6c5694
...@@ -58,21 +58,24 @@ struct comedi_driver *comedi_drivers; ...@@ -58,21 +58,24 @@ struct comedi_driver *comedi_drivers;
int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
{ {
struct comedi_subdevice *s;
int i; int i;
if (num_subdevices < 1) if (num_subdevices < 1)
return -EINVAL; return -EINVAL;
dev->subdevices =
kcalloc(num_subdevices, sizeof(struct comedi_subdevice), s = kcalloc(num_subdevices, sizeof(*s), GFP_KERNEL);
GFP_KERNEL); if (!s)
if (!dev->subdevices)
return -ENOMEM; return -ENOMEM;
dev->subdevices = s;
dev->n_subdevices = num_subdevices; dev->n_subdevices = num_subdevices;
for (i = 0; i < num_subdevices; ++i) { for (i = 0; i < num_subdevices; ++i) {
dev->subdevices[i].device = dev; s = dev->subdevices + i;
dev->subdevices[i].async_dma_dir = DMA_NONE; s->device = dev;
spin_lock_init(&dev->subdevices[i].spin_lock); s->async_dma_dir = DMA_NONE;
dev->subdevices[i].minor = -1; spin_lock_init(&s->spin_lock);
s->minor = -1;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment