Staging: comedi: Remove COMEDI_PCI_INITCLEANUP macro
[deliverable/linux.git] / drivers / staging / comedi / drivers / skel.c
index aba57d93dd3d7cbdf2c2fc718bb8514abb904d3c..732a323ab71036d6680e1b1986981d33ec12de27 100644 (file)
@@ -131,7 +131,8 @@ MODULE_DEVICE_TABLE(pci, skel_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 skel_private {
 
        int data;
@@ -211,7 +212,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        struct comedi_subdevice *s;
 
-       printk("comedi%d: skel: ", dev->minor);
+       pr_info("comedi%d: skel: ", dev->minor);
 
 /*
  * If you can probe the device to determine what device in a series
@@ -282,7 +283,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                s->type = COMEDI_SUBD_UNUSED;
        }
 
-       printk("attached\n");
+       pr_info("attached\n");
 
        return 0;
 }
@@ -297,7 +298,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
  */
 static int skel_detach(struct comedi_device *dev)
 {
-       printk("comedi%d: skel: remove\n", dev->minor);
+       pr_info("comedi%d: skel: remove\n", dev->minor);
 
        return 0;
 }
@@ -336,7 +337,7 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
                if (i == TIMEOUT) {
                        /* printk() should be used instead of printk()
                         * whenever the code can be called from real-time. */
-                       printk("timeout\n");
+                       pr_info("timeout\n");
                        return -ETIMEDOUT;
                }
 
@@ -397,7 +398,8 @@ static int skel_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 1;
 
-       /* step 2: make sure trigger sources are unique and mutually compatible */
+       /* step 2: make sure trigger sources are unique and mutually compatible
+     */
 
        /* note that mutual compatibility is not an issue here */
        if (cmd->scan_begin_src != TRIG_TIMER &&
@@ -529,7 +531,7 @@ static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
        int i;
        int chan = CR_CHAN(insn->chanspec);
 
-       printk("skel_ao_winsn\n");
+       pr_info("skel_ao_winsn\n");
        /* Writing a list of values to an AO channel is probably not
         * very useful, but that's how the interface is defined. */
        for (i = 0; i < insn->n; i++) {
@@ -618,11 +620,59 @@ static int skel_dio_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-COMEDI_INITCLEANUP(driver_skel);
-/* If you are writing a PCI driver you should use COMEDI_PCI_INITCLEANUP instead.
-*/
-/* COMEDI_PCI_INITCLEANUP(driver_skel, skel_pci_table) */
+#ifdef CONFIG_COMEDI_PCI
+static int __devinit driver_skel_pci_probe(struct pci_dev *dev,
+                                          const struct pci_device_id *ent)
+{
+       return comedi_pci_auto_config(dev, driver_skel.driver_name);
+}
+
+static void __devexit driver_skel_pci_remove(struct pci_dev *dev)
+{
+       comedi_pci_auto_unconfig(dev);
+}
+
+static struct pci_driver driver_skel_pci_driver = {
+       .id_table = skel_pci_table,
+       .probe = &driver_skel_pci_probe,
+       .remove = __devexit_p(&driver_skel_pci_remove)
+};
+
+static int __init driver_skel_init_module(void)
+{
+       int retval;
+
+       retval = comedi_driver_register(&driver_skel);
+       if (retval < 0)
+               return retval;
+
+       driver_skel_pci_driver.name = (char *)driver_skel.driver_name;
+       return pci_register_driver(&driver_skel_pci_driver);
+}
+
+static void __exit driver_skel_cleanup_module(void)
+{
+       pci_unregister_driver(&driver_skel_pci_driver);
+       comedi_driver_unregister(&driver_skel);
+}
+
+module_init(driver_skel_init_module);
+module_exit(driver_skel_cleanup_module);
+#else
+static int __init driver_skel_init_module(void)
+{
+       return comedi_driver_register(&driver_skel);
+}
+
+static void __exit driver_skel_cleanup_module(void)
+{
+       comedi_driver_unregister(&driver_skel);
+}
+
+module_init(driver_skel_init_module);
+module_exit(driver_skel_cleanup_module);
+#endif
+
+MODULE_AUTHOR("Comedi http://www.comedi.org");
+MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_LICENSE("GPL");
This page took 0.029633 seconds and 5 git commands to generate.