staging: comedi: refactor pcl711 driver to remove the forward declarations
authorH Hartley Sweeten <hartleys@visionengravers.com>
Sat, 28 Apr 2012 00:13:48 +0000 (17:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 Apr 2012 01:42:50 +0000 (21:42 -0400)
Move the module_init/module_exit routines and the associated
struct comedi_driver and other variables to the end of the source.
This is more typical of how other drivers are written and removes
the need for the forward declarations.

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/pcl711.c

index ce6e514..fcb7cea 100644 (file)
@@ -148,41 +148,8 @@ struct pcl711_board {
        const struct comedi_lrange *ai_range_type;
 };
 
-static const struct pcl711_board boardtypes[] = {
-       {"pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5},
-       {"pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai},
-       {"acl8112hg", 0, 1, 0, 12, 16, 2, 15, &range_acl8112hg_ai},
-       {"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai},
-};
-
 #define this_board ((const struct pcl711_board *)dev->board_ptr)
 
-static int pcl711_attach(struct comedi_device *dev,
-                        struct comedi_devconfig *it);
-static int pcl711_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcl711 = {
-       .driver_name = "pcl711",
-       .module = THIS_MODULE,
-       .attach = pcl711_attach,
-       .detach = pcl711_detach,
-       .board_name = &boardtypes[0].name,
-       .num_names = ARRAY_SIZE(boardtypes),
-       .offset = sizeof(struct pcl711_board),
-};
-
-static int __init driver_pcl711_init_module(void)
-{
-       return comedi_driver_register(&driver_pcl711);
-}
-
-static void __exit driver_pcl711_cleanup_module(void)
-{
-       comedi_driver_unregister(&driver_pcl711);
-}
-
-module_init(driver_pcl711_init_module);
-module_exit(driver_pcl711_cleanup_module);
-
 struct pcl711_private {
 
        int board;
@@ -512,21 +479,6 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,
        return 2;
 }
 
-/*  Free any resources that we have claimed  */
-static int pcl711_detach(struct comedi_device *dev)
-{
-       printk(KERN_INFO "comedi%d: pcl711: remove\n", dev->minor);
-
-       if (dev->irq)
-               free_irq(dev->irq, dev);
-
-       if (dev->iobase)
-               release_region(dev->iobase, PCL711_SIZE);
-
-       return 0;
-}
-
-/*  Initialization */
 static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        int ret;
@@ -639,6 +591,48 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        return 0;
 }
 
+static int pcl711_detach(struct comedi_device *dev)
+{
+       printk(KERN_INFO "comedi%d: pcl711: remove\n", dev->minor);
+
+       if (dev->irq)
+               free_irq(dev->irq, dev);
+
+       if (dev->iobase)
+               release_region(dev->iobase, PCL711_SIZE);
+
+       return 0;
+}
+
+static const struct pcl711_board boardtypes[] = {
+       { "pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5 },
+       { "pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai },
+       { "acl8112hg", 0, 1, 0, 12, 16, 2, 15, &range_acl8112hg_ai },
+       { "acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai },
+};
+
+static struct comedi_driver driver_pcl711 = {
+       .driver_name    = "pcl711",
+       .module         = THIS_MODULE,
+       .attach         = pcl711_attach,
+       .detach         = pcl711_detach,
+       .board_name     = &boardtypes[0].name,
+       .num_names      = ARRAY_SIZE(boardtypes),
+       .offset         = sizeof(struct pcl711_board),
+};
+
+static int __init driver_pcl711_init_module(void)
+{
+       return comedi_driver_register(&driver_pcl711);
+}
+module_init(driver_pcl711_init_module);
+
+static void __exit driver_pcl711_cleanup_module(void)
+{
+       comedi_driver_unregister(&driver_pcl711);
+}
+module_exit(driver_pcl711_cleanup_module);
+
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");