Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f0b9d08 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: export alloc_subdevices as comedi_alloc_subdevices



Move the inline alloc_subdevices() function from comedidev.h
to drivers.c and rename it to comedi_alloc_subdevices(). The
function is large enough to warrant being an exported symbol
rather than being an inline in every driver.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e3499514
Loading
Loading
Loading
Loading
+2 −20
Original line number Diff line number Diff line
@@ -292,6 +292,8 @@ static inline struct comedi_subdevice *comedi_get_write_subdevice(
	return info->device->write_subdev;
}

int comedi_alloc_subdevices(struct comedi_device *, unsigned int);

void comedi_device_detach(struct comedi_device *dev);
int comedi_device_attach(struct comedi_device *dev,
			 struct comedi_devconfig *it);
@@ -413,26 +415,6 @@ struct comedi_lrange {

/* some silly little inline functions */

static inline int alloc_subdevices(struct comedi_device *dev,
				   unsigned int num_subdevices)
{
	unsigned i;

	dev->n_subdevices = num_subdevices;
	dev->subdevices =
	    kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
		    GFP_KERNEL);
	if (!dev->subdevices)
		return -ENOMEM;
	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;
	}
	return 0;
}

static inline int alloc_private(struct comedi_device *dev, int size)
{
	dev->private = kzalloc(size, GFP_KERNEL);
+21 −0
Original line number Diff line number Diff line
@@ -56,6 +56,27 @@ static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);

struct comedi_driver *comedi_drivers;

int comedi_alloc_subdevices(struct comedi_device *dev,
			    unsigned int num_subdevices)
{
	unsigned i;

	dev->n_subdevices = num_subdevices;
	dev->subdevices =
	    kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
		    GFP_KERNEL);
	if (!dev->subdevices)
		return -ENOMEM;
	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;
	}
	return 0;
}
EXPORT_SYMBOL_GPL(comedi_alloc_subdevices);

static void cleanup_device(struct comedi_device *dev)
{
	int i;
+1 −1
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ static int dev_8255_attach(struct comedi_device *dev,
		return -EINVAL;
	}

	ret = alloc_subdevices(dev, i);
	ret = comedi_alloc_subdevices(dev, i);
	if (ret < 0) {
		/* FIXME this printk call should give a proper message, the
		 * below line just maintains previous functionality */
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ static int acl7225b_attach(struct comedi_device *dev,
	dev->iobase = iobase;
	dev->irq = 0;

	if (alloc_subdevices(dev, 3) < 0)
	if (comedi_alloc_subdevices(dev, 3) < 0)
		return -ENOMEM;

	s = dev->subdevices + 0;
+1 −1
Original line number Diff line number Diff line
@@ -1688,7 +1688,7 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
	} else {
		/* Update-0.7.57->0.7.68dev->n_subdevices = 7; */
		n_subdevices = 7;
		ret = alloc_subdevices(dev, n_subdevices);
		ret = comedi_alloc_subdevices(dev, n_subdevices);
		if (ret < 0)
			return ret;

Loading