Staging: comedi: Remove COMEDI_PCI_INITCLEANUP macro
[deliverable/linux.git] / drivers / staging / comedi / drivers / amplc_pc236.c
index 1032a8110d6e7915bfc10e756727c601934d8eb9..48246cd50d470fa499eca602b553e90c272158bc 100644 (file)
@@ -78,18 +78,18 @@ unused.
  */
 /* Disable interrupt, also clear any interrupt there */
 #define PCI236_INTR_DISABLE (PLX9052_INTCSR_LI1ENAB_DISABLED \
-        | PLX9052_INTCSR_LI1POL_HIGH \
-        | PLX9052_INTCSR_LI2POL_HIGH \
-        | PLX9052_INTCSR_PCIENAB_DISABLED \
-        | PLX9052_INTCSR_LI1SEL_EDGE \
-        | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
+       | PLX9052_INTCSR_LI1POL_HIGH \
+       | PLX9052_INTCSR_LI2POL_HIGH \
+       | PLX9052_INTCSR_PCIENAB_DISABLED \
+       | PLX9052_INTCSR_LI1SEL_EDGE \
+       | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
 /* Enable interrupt, also clear any interrupt there. */
 #define PCI236_INTR_ENABLE (PLX9052_INTCSR_LI1ENAB_ENABLED \
-        | PLX9052_INTCSR_LI1POL_HIGH \
-        | PLX9052_INTCSR_LI2POL_HIGH \
-        | PLX9052_INTCSR_PCIENAB_ENABLED \
-        | PLX9052_INTCSR_LI1SEL_EDGE \
-        | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
+       | PLX9052_INTCSR_LI1POL_HIGH \
+       | PLX9052_INTCSR_LI2POL_HIGH \
+       | PLX9052_INTCSR_PCIENAB_ENABLED \
+       | PLX9052_INTCSR_LI1SEL_EDGE \
+       | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
 
 /*
  * Board descriptions for Amplicon PC36AT and PCI236.
@@ -150,12 +150,13 @@ MODULE_DEVICE_TABLE(pci, pc236_pci_table);
 
 /* this structure is for data unique to this hardware driver.  If
    several hardware drivers keep similar information in this structure,
-   feel free to suggest moving the variable to the struct comedi_device struct.  */
+   feel free to suggest moving the variable to the struct comedi_device struct.
+ */
 struct pc236_private {
 #ifdef CONFIG_COMEDI_PCI
        /* PCI device */
        struct pci_dev *pci_dev;
-       unsigned long lcr_iobase;       /* PLX PCI9052 config registers in PCIBAR1 */
+       unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
 #endif
        int enable_irq;
 };
@@ -181,9 +182,58 @@ static struct comedi_driver driver_amplc_pc236 = {
 };
 
 #ifdef CONFIG_COMEDI_PCI
-COMEDI_PCI_INITCLEANUP(driver_amplc_pc236, pc236_pci_table);
+static int __devinit driver_amplc_pc236_pci_probe(struct pci_dev *dev,
+                                                 const struct pci_device_id
+                                                 *ent)
+{
+       return comedi_pci_auto_config(dev, driver_amplc_pc236.driver_name);
+}
+
+static void __devexit driver_amplc_pc236_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static struct pci_driver driver_amplc_pc236_pci_driver = {
+       .id_table = pc236_pci_table,
+       .probe = &driver_amplc_pc236_pci_probe,
+       .remove = __devexit_p(&driver_amplc_pc236_pci_remove)
+};
+
+static int __init driver_amplc_pc236_init_module(void)
+{
+       int retval;
+
+       retval = comedi_driver_register(&driver_amplc_pc236);
+       if (retval < 0)
+               return retval;
+
+       driver_amplc_pc236_pci_driver.name =
+           (char *)driver_amplc_pc236.driver_name;
+       return pci_register_driver(&driver_amplc_pc236_pci_driver);
+}
+
+static void __exit driver_amplc_pc236_cleanup_module(void)
+{
+       pci_unregister_driver(&driver_amplc_pc236_pci_driver);
+       comedi_driver_unregister(&driver_amplc_pc236);
+}
+
+module_init(driver_amplc_pc236_init_module);
+module_exit(driver_amplc_pc236_cleanup_module);
 #else
-COMEDI_INITCLEANUP(driver_amplc_pc236);
+static int __init driver_amplc_pc236_init_module(void)
+{
+       return comedi_driver_register(&driver_amplc_pc236);
+}
+
+static void __exit driver_amplc_pc236_cleanup_module(void)
+{
+       comedi_driver_unregister(&driver_amplc_pc236);
+}
+
+module_init(driver_amplc_pc236_init_module);
+module_exit(driver_amplc_pc236_cleanup_module);
 #endif
 
 static int pc236_request_region(unsigned minor, unsigned long from,
@@ -345,9 +395,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif
        {
                ret = pc236_request_region(dev->minor, iobase, PC236_IO_SIZE);
-               if (ret < 0) {
+               if (ret < 0)
                        return ret;
-               }
        }
        dev->iobase = iobase;
 
@@ -399,11 +448,10 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                printk("(pci %s) ", pci_name(pci_dev));
 #endif
        }
-       if (irq) {
+       if (irq)
                printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE"));
-       } else {
+       else
                printk("(no irq) ");
-       }
 
        printk("attached\n");
 
@@ -422,27 +470,24 @@ static int pc236_detach(struct comedi_device *dev)
 {
        printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
               PC236_DRIVER_NAME);
-       if (devpriv) {
+       if (devpriv)
                pc236_intr_disable(dev);
-       }
+
        if (dev->irq)
                free_irq(dev->irq, dev);
-       if (dev->subdevices) {
+       if (dev->subdevices)
                subdev_8255_cleanup(dev, dev->subdevices + 0);
-       }
        if (devpriv) {
 #ifdef CONFIG_COMEDI_PCI
                if (devpriv->pci_dev) {
-                       if (dev->iobase) {
+                       if (dev->iobase)
                                comedi_pci_disable(devpriv->pci_dev);
-                       }
                        pci_dev_put(devpriv->pci_dev);
                } else
 #endif
                {
-                       if (dev->iobase) {
+                       if (dev->iobase)
                                release_region(dev->iobase, PC236_IO_SIZE);
-                       }
                }
        }
        if (dev->board_name) {
@@ -668,3 +713,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
        }
        return IRQ_RETVAL(handled);
 }
+
+MODULE_AUTHOR("Comedi http://www.comedi.org");
+MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_LICENSE("GPL");
This page took 0.029354 seconds and 5 git commands to generate.