]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: refactor daqboard2000 driver and use module_comedi_pci_driver
authorH Hartley Sweeten <hartleys@visionengravers.com>
Wed, 16 May 2012 01:29:18 +0000 (18:29 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 May 2012 20:23:02 +0000 (13:23 -0700)
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>
drivers/staging/comedi/drivers/daqboard2000.c

index 480f418b28c1f29ae293431a8b2a03e951b99953..dc974ce24ebf598565a5d3fb718fe9fd74850549 100644 (file)
@@ -301,17 +301,6 @@ struct daqboard2000_hw {
 #define DAQBOARD2000_PosRefDacSelect             0x0100
 #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 {
        const char *name;
        int id;
@@ -323,13 +312,6 @@ static const struct daq200_boardtype boardtypes[] = {
 
 #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 {
        enum {
                card_daqboard_2000
@@ -876,45 +858,37 @@ static int daqboard2000_detach(struct comedi_device *dev)
        return 0;
 }
 
-static int __devinit driver_daqboard2000_pci_probe(struct pci_dev *dev,
-                                                  const struct pci_device_id
-                                                  *ent)
+static struct comedi_driver daqboard2000_driver = {
+       .driver_name    = "daqboard2000",
+       .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);
 }
 
-static struct pci_driver driver_daqboard2000_pci_driver = {
-       .id_table = daqboard2000_pci_table,
-       .probe = &driver_daqboard2000_pci_probe,
-       .remove = __devexit_p(&driver_daqboard2000_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
+       { PCI_DEVICE(0x1616, 0x0409) },
+       { 0 }
 };
+MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
 
-static int __init driver_daqboard2000_init_module(void)
-{
-       int retval;
-
-       retval = comedi_driver_register(&driver_daqboard2000);
-       if (retval < 0)
-               return retval;
-
-       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);
+static struct pci_driver daqboard2000_pci_driver = {
+       .name           = "daqboard2000",
+       .id_table       = daqboard2000_pci_table,
+       .probe          = daqboard2000_pci_probe,
+       .remove         = __devexit_p(daqboard2000_pci_remove),
+};
+module_comedi_pci_driver(daqboard2000_driver, daqboard2000_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");