staging: comedi: refactor daqboard2000 driver and use module_comedi_pci_driver

Move the module_init/module_exit routines and the associated
struct comedi_drive and struct pci_driver to the end of the
source. This is more typical of how other drivers are written
and removes the need for the forward declarations.

Convert the driver to use the module_comedi_pci_driver() macro
which makes the code smaller and a bit simpler.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2012-05-15 18:29:18 -07:00 committed by Greg Kroah-Hartman
parent 1e991a14db
commit ace44dc8ac
1 changed files with 22 additions and 48 deletions

View File

@ -301,17 +301,6 @@ struct daqboard2000_hw {
#define DAQBOARD2000_PosRefDacSelect 0x0100 #define DAQBOARD2000_PosRefDacSelect 0x0100
#define DAQBOARD2000_NegRefDacSelect 0x0000 #define DAQBOARD2000_NegRefDacSelect 0x0000
static int daqboard2000_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
static int daqboard2000_detach(struct comedi_device *dev);
static struct comedi_driver driver_daqboard2000 = {
.driver_name = "daqboard2000",
.module = THIS_MODULE,
.attach = daqboard2000_attach,
.detach = daqboard2000_detach,
};
struct daq200_boardtype { struct daq200_boardtype {
const char *name; const char *name;
int id; int id;
@ -323,13 +312,6 @@ static const struct daq200_boardtype boardtypes[] = {
#define this_board ((const struct daq200_boardtype *)dev->board_ptr) #define this_board ((const struct daq200_boardtype *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
{ PCI_DEVICE(0x1616, 0x0409) },
{0}
};
MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
struct daqboard2000_private { struct daqboard2000_private {
enum { enum {
card_daqboard_2000 card_daqboard_2000
@ -876,45 +858,37 @@ static int daqboard2000_detach(struct comedi_device *dev)
return 0; return 0;
} }
static int __devinit driver_daqboard2000_pci_probe(struct pci_dev *dev, static struct comedi_driver daqboard2000_driver = {
const struct pci_device_id .driver_name = "daqboard2000",
*ent) .module = THIS_MODULE,
.attach = daqboard2000_attach,
.detach = daqboard2000_detach,
};
static int __devinit daqboard2000_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{ {
return comedi_pci_auto_config(dev, &driver_daqboard2000); return comedi_pci_auto_config(dev, &daqboard2000_driver);
} }
static void __devexit driver_daqboard2000_pci_remove(struct pci_dev *dev) static void __devexit daqboard2000_pci_remove(struct pci_dev *dev)
{ {
comedi_pci_auto_unconfig(dev); comedi_pci_auto_unconfig(dev);
} }
static struct pci_driver driver_daqboard2000_pci_driver = { static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
.id_table = daqboard2000_pci_table, { PCI_DEVICE(0x1616, 0x0409) },
.probe = &driver_daqboard2000_pci_probe, { 0 }
.remove = __devexit_p(&driver_daqboard2000_pci_remove)
}; };
MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
static int __init driver_daqboard2000_init_module(void) static struct pci_driver daqboard2000_pci_driver = {
{ .name = "daqboard2000",
int retval; .id_table = daqboard2000_pci_table,
.probe = daqboard2000_pci_probe,
retval = comedi_driver_register(&driver_daqboard2000); .remove = __devexit_p(daqboard2000_pci_remove),
if (retval < 0) };
return retval; module_comedi_pci_driver(daqboard2000_driver, daqboard2000_pci_driver);
driver_daqboard2000_pci_driver.name =
(char *)driver_daqboard2000.driver_name;
return pci_register_driver(&driver_daqboard2000_pci_driver);
}
static void __exit driver_daqboard2000_cleanup_module(void)
{
pci_unregister_driver(&driver_daqboard2000_pci_driver);
comedi_driver_unregister(&driver_daqboard2000);
}
module_init(driver_daqboard2000_init_module);
module_exit(driver_daqboard2000_cleanup_module);
MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_DESCRIPTION("Comedi low-level driver");