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

staging: comedi: remove inline alloc_private()



This inline function has a very generic name and it's only a
wrapper around a simple kzalloc(). Since the inline function
does not save any lines-of-code, instead of renaming it just
remove it and do the kzalloc() directly.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a51d0206
......@@ -415,14 +415,6 @@ struct comedi_lrange {
/* some silly little inline functions */
static inline int alloc_private(struct comedi_device *dev, int size)
{
dev->private = kzalloc(size, GFP_KERNEL);
if (!dev->private)
return -ENOMEM;
return 0;
}
static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
{
if (subd->subdev_flags & SDF_LSAMPL)
......
......@@ -235,10 +235,10 @@ static int pci_8255_attach_pci(struct comedi_device *dev,
dev->board_ptr = board;
dev->board_name = board->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -1482,10 +1482,10 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned char pci_bus, pci_slot, pci_func;
int i_Dma = 0;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
if (!pci_list_builded) {
v_pci_card_list_init(this_board->i_VendorId, 1); /* 1 for displaying the list.. */
......
......@@ -191,10 +191,10 @@ static int pci6208_attach_pci(struct comedi_device *dev,
dev->board_ptr = boardinfo;
dev->board_name = boardinfo->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -889,10 +889,10 @@ static int pci9111_attach_pci(struct comedi_device *dev,
comedi_set_hw_dev(dev, &pcidev->dev);
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*dev_private));
if (ret)
return ret;
dev_private = dev->private;
dev_private = kzalloc(sizeof(*dev_private), GFP_KERNEL);
if (!dev_private)
return -ENOMEM;
dev->private = dev_private;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -1923,10 +1923,10 @@ static int pci9118_attach(struct comedi_device *dev,
else
master = 1;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
pcidev = pci9118_find_pci(dev, it);
if (!pcidev)
......
......@@ -243,10 +243,10 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev->iobase = iobase;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
devpriv->unipolar = unipolar;
devpriv->differential = differential;
......
......@@ -1273,10 +1273,10 @@ static int pci1710_attach_pci(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -244,10 +244,10 @@ static int pci1723_attach_pci(struct comedi_device *dev,
comedi_set_hw_dev(dev, &pcidev->dev);
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -1108,10 +1108,10 @@ static int pci_dio_attach_pci(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -212,10 +212,10 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
}
dev->iobase = iobase;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
......
......@@ -1339,10 +1339,10 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach\n");
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
/* Process options and reserve resources according to bus type. */
if (is_isa_board(thisboard)) {
......@@ -1378,7 +1378,6 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
struct pci_dev *pci_dev)
{
struct dio200_private *devpriv;
int ret;
if (!DO_PCI)
return -EINVAL;
......@@ -1386,10 +1385,10 @@ static int __devinit dio200_attach_pci(struct comedi_device *dev,
dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach pci %s\n",
pci_name(pci_dev));
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
dev->board_ptr = dio200_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
......
......@@ -510,10 +510,10 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach\n");
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
/* Process options according to bus type. */
if (is_isa_board(thisboard)) {
......@@ -546,7 +546,6 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
struct pci_dev *pci_dev)
{
struct pc236_private *devpriv;
int ret;
if (!DO_PCI)
return -EINVAL;
......@@ -554,10 +553,10 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
pci_name(pci_dev));
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
dev->board_ptr = pc236_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
......
......@@ -1445,14 +1445,13 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci224_private *devpriv;
struct pci_dev *pci_dev;
int ret;
dev_info(dev->class_dev, DRIVER_NAME ": attach\n");
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
pci_dev = pci224_find_pci_dev(dev, it);
if (!pci_dev)
......@@ -1465,15 +1464,14 @@ static int __devinit
pci224_attach_pci(struct comedi_device *dev, struct pci_dev *pci_dev)
{
struct pci224_private *devpriv;
int ret;
dev_info(dev->class_dev, DRIVER_NAME ": attach_pci %s\n",
pci_name(pci_dev));
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
dev->board_ptr = pci224_find_pci_board(pci_dev);
if (dev->board_ptr == NULL) {
......
......@@ -2660,12 +2660,11 @@ static struct pci_dev *pci230_find_pci_dev(struct comedi_device *dev,
static int pci230_alloc_private(struct comedi_device *dev)
{
struct pci230_private *devpriv;
int err;
err = alloc_private(dev, sizeof(*devpriv));
if (err)
return err;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
spin_lock_init(&devpriv->isr_spinlock);
spin_lock_init(&devpriv->res_spinlock);
......
......@@ -452,10 +452,10 @@ static int das16cs_attach(struct comedi_device *dev,
return ret;
dev->irq = link->irq;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_alloc_subdevices(dev, 3);
if (ret)
......
......@@ -1486,10 +1486,10 @@ static int cb_pcidas_attach_pci(struct comedi_device *dev,
dev->board_ptr = thisboard;
dev->board_name = thisboard->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -1688,10 +1688,10 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
uint32_t local_range, local_decode;
int retval;
retval = alloc_private(dev, sizeof(*devpriv));
if (retval)
return retval;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
pcidev = cb_pcidas64_find_pci_dev(dev, it);
if (!pcidev)
......
......@@ -664,10 +664,10 @@ static int cb_pcidda_attach_pci(struct comedi_device *dev,
dev->board_ptr = thisboard;
dev->board_name = thisboard->name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
......@@ -219,10 +219,10 @@ static int cb_pcimdas_attach_pci(struct comedi_device *dev,
dev->board_name = dev->driver->driver_name;
ret = alloc_private(dev, sizeof(*devpriv));
if (ret)
return ret;
devpriv = dev->private;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(pcidev, dev->board_name);
if (ret)
......
Supports Markdown
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