mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Frank Mori Hess <fmhess@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e34995148a
commit
2f0b9d082e
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ void i_ADDI_AttachPCI1710(struct comedi_device *dev)
|
||||
int n_subdevices = 9;
|
||||
|
||||
/* Update-0.7.57->0.7.68dev->n_subdevices = 9; */
|
||||
ret = alloc_subdevices(dev, n_subdevices);
|
||||
ret = comedi_alloc_subdevices(dev, n_subdevices);
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ static int pci6208_attach(struct comedi_device *dev,
|
||||
dev->iobase = io_base;
|
||||
dev->board_name = thisboard->name;
|
||||
|
||||
if (alloc_subdevices(dev, 2) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 2) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
s = dev->subdevices + 0;
|
||||
|
||||
@@ -116,7 +116,7 @@ static int adl_pci7230_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct adl_pci7230_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 2) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 2) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
devpriv->pci_dev = adl_pci7230_find_pci(dev, it);
|
||||
|
||||
@@ -92,7 +92,7 @@ static int adl_pci7296_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct adl_pci7296_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 4) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 4) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
devpriv->pci_dev = adl_pci7296_find_pci(dev, it);
|
||||
|
||||
@@ -125,7 +125,7 @@ static int adl_pci7432_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct adl_pci7432_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 2) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 2) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
devpriv->pci_dev = adl_pci7432_find_pci(dev, it);
|
||||
|
||||
@@ -261,7 +261,7 @@ static int adl_pci8164_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct adl_pci8164_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 4) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 4) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
devpriv->pci_dev = adl_pci8164_find_pci(dev, it);
|
||||
|
||||
@@ -1317,7 +1317,7 @@ static int pci9111_attach(struct comedi_device *dev,
|
||||
|
||||
/* TODO: Add external multiplexer setup (according to option[2]). */
|
||||
|
||||
error = alloc_subdevices(dev, 4);
|
||||
error = comedi_alloc_subdevices(dev, 4);
|
||||
if (error < 0)
|
||||
return error;
|
||||
|
||||
|
||||
@@ -2268,7 +2268,7 @@ static int pci9118_attach(struct comedi_device *dev,
|
||||
pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64);
|
||||
/* Enable parity check for parity error */
|
||||
|
||||
ret = alloc_subdevices(dev, 4);
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
* Allocate the subdevice structures. alloc_subdevice() is a
|
||||
* convenient macro defined in comedidev.h.
|
||||
*/
|
||||
if (alloc_subdevices(dev, 3) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 3) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
s = dev->subdevices + 0;
|
||||
|
||||
@@ -1433,7 +1433,7 @@ static int pci1710_attach(struct comedi_device *dev,
|
||||
if (this_board->n_counter)
|
||||
n_subdevices++;
|
||||
|
||||
ret = alloc_subdevices(dev, n_subdevices);
|
||||
ret = comedi_alloc_subdevices(dev, n_subdevices);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ static int pci1723_attach(struct comedi_device *dev,
|
||||
if (this_board->n_diochan)
|
||||
n_subdevices++;
|
||||
|
||||
ret = alloc_subdevices(dev, n_subdevices);
|
||||
ret = comedi_alloc_subdevices(dev, n_subdevices);
|
||||
if (ret < 0) {
|
||||
printk(" - Allocation failed!\n");
|
||||
return ret;
|
||||
|
||||
@@ -1156,7 +1156,7 @@ static int pci_dio_attach(struct comedi_device *dev,
|
||||
n_subdevices++;
|
||||
}
|
||||
|
||||
ret = alloc_subdevices(dev, n_subdevices);
|
||||
ret = comedi_alloc_subdevices(dev, n_subdevices);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct aio12_8_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 3) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 3) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
s = &dev->subdevices[0];
|
||||
|
||||
@@ -124,7 +124,7 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
|
||||
if (alloc_private(dev, sizeof(struct aio_iiro_16_private)) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
if (alloc_subdevices(dev, 2) < 0)
|
||||
if (comedi_alloc_subdevices(dev, 2) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
s = dev->subdevices + 0;
|
||||
|
||||
@@ -1273,7 +1273,7 @@ static int dio200_common_attach(struct comedi_device *dev, unsigned long iobase,
|
||||
devpriv->intr_sd = -1;
|
||||
dev->iobase = iobase;
|
||||
dev->board_name = thisboard->name;
|
||||
ret = alloc_subdevices(dev, layout->n_subdevs);
|
||||
ret = comedi_alloc_subdevices(dev, layout->n_subdevs);
|
||||
if (ret < 0) {
|
||||
dev_err(dev->class_dev, "error! out of memory!\n");
|
||||
return ret;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user