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

staging: comedi: use comedi_alloc_devpriv()



Use the helper function to allocate memory and set the comedi_device
private data pointer.

This removes the dependency on slab.h from most of the drivers so
remove the global #include in comedidev.h and the local #include
in some of the drivers.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 54db996e
......@@ -22,7 +22,6 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
......
......@@ -186,10 +186,9 @@ static int pci_8255_auto_attach(struct comedi_device *dev,
dev->board_ptr = board;
dev->board_name = board->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -85,10 +85,9 @@ static int addi_auto_attach(struct comedi_device *dev,
dev->board_name = this_board->pc_DriverName;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -289,10 +289,9 @@ static int apci1032_auto_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
int ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -136,10 +136,9 @@ static int apci1516_auto_attach(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -35,10 +35,9 @@ static int apci1710_auto_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
int ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -65,10 +65,9 @@ static int apci3120_auto_attach(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->pc_DriverName;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -332,10 +332,9 @@ static int apci3501_auto_attach(struct comedi_device *dev,
int ao_n_chan;
int ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -801,10 +801,9 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
dev->board_ptr = board;
dev->board_name = board->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -172,10 +172,9 @@ static int pci6208_auto_attach(struct comedi_device *dev,
dev->board_ptr = boardinfo;
dev->board_name = boardinfo->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -855,10 +855,9 @@ static int pci9111_auto_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
int ret;
dev_private = kzalloc(sizeof(*dev_private), GFP_KERNEL);
dev_private = comedi_alloc_devpriv(dev, sizeof(*dev_private));
if (!dev_private)
return -ENOMEM;
dev->private = dev_private;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -2140,10 +2140,9 @@ static int pci9118_attach(struct comedi_device *dev,
softsshdelay = it->options[4];
hw_err_mask = it->options[5];
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
pcidev = pci9118_find_pci(dev, it);
if (!pcidev)
......@@ -2160,10 +2159,9 @@ static int pci9118_auto_attach(struct comedi_device *dev,
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct pci9118_private *devpriv;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
dev->board_ptr = pci9118_find_boardinfo(pcidev);
if (dev->board_ptr == NULL) {
......
......@@ -214,10 +214,9 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret)
return ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
devpriv->unipolar = it->options[1];
devpriv->differential = it->options[2];
......
......@@ -1233,10 +1233,9 @@ static int pci1710_auto_attach(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -237,10 +237,9 @@ static int pci1723_auto_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
int ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -340,10 +340,9 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev,
int retval;
unsigned int board_id;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
/* init software copies of output values to indicate we don't know
* what the output value is since it has never been written. */
......
......@@ -1107,10 +1107,9 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
dev->board_ptr = this_board;
dev->board_name = this_board->name;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_pci_enable(dev);
if (ret)
......
......@@ -202,10 +202,9 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
if (ret)
return ret;
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_alloc_subdevices(dev, 4);
if (ret)
......
......@@ -192,8 +192,6 @@
* order they appear in the channel list.
*/
#include <linux/slab.h>
#include "../comedidev.h"
#include "amplc_dio200.h"
......@@ -272,10 +270,9 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
irq = it->options[1];
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;
ret = comedi_request_region(dev, it->options[0], thisboard->mainsize);
if (ret)
......
......@@ -20,7 +20,6 @@
*/
#include <linux/interrupt.h>
#include <linux/slab.h>
#include "../comedidev.h"
......
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