]> Pileus Git - ~andy/linux/commitdiff
staging: comedi: das08: separately configure ISA and PCI
authorIan Abbott <abbotti@mev.co.uk>
Mon, 26 Mar 2012 15:57:29 +0000 (16:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Apr 2012 18:16:13 +0000 (11:16 -0700)
The das08 driver supports both ISA and PCI cards, but currently is
configured outside the ISA and PCI comedi driver sections.  The module
is also used by the das08_cs driver.  This patch splits the
configuration to make the ISA and PCI parts separately selectable, and
changes the driver to only include the selected ISA and/or PCI board
types.  Also, if neither the ISA or PCI parts are selected, and the
module is only needed for the das08_cs driver, don't register the driver
as a comedi driver as it doesn't have any boards to support.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/Kconfig
drivers/staging/comedi/drivers/das08.c

index 391a713ff2b53c738b914fec46581db31b1bfe13..9037d02939ffae751eead2d8b0d9075f55257b77 100644 (file)
@@ -272,6 +272,20 @@ config COMEDI_DAS16M1
          To compile this driver as a module, choose M here: the module will be
          called das16m1.
 
+config COMEDI_DAS08_ISA
+       tristate "DAS-08 compatible ISA and PC/104 card support"
+       select COMEDI_DAS08
+       default N
+       ---help---
+         Enable support for Keithley Metrabyte/ComputerBoards DAS08
+         and compatible ISA and PC/104 cards:
+         Keithley Metrabyte/ComputerBoards DAS08, DAS08-PGM, DAS08-PGH,
+         DAS08-PGL, DAS08-AOH, DAS08-AOL, DAS08-AOM, DAS08/JR-AO,
+         DAS08/JR-16-AO, PC104-DAS08, DAS08/JR/16.
+
+         To compile this driver as a module, choose M here: the module will be
+         called das08.
+
 config COMEDI_DAS16
        tristate "DAS-16 compatible ISA and PC/104 card support"
        select COMEDI_8255
@@ -864,6 +878,16 @@ config COMEDI_CONTEC_PCI_DIO
          To compile this driver as a module, choose M here: the module will be
          called contec_pci_dio.
 
+config COMEDI_DAS08_PCI
+       tristate "DAS-08 PCI support"
+       select COMEDI_DAS08
+       default N
+       ---help---
+         Enable support for PCI DAS-08 cards.
+
+         To compile this driver as a module, choose M here: the module will be
+         called das08.
+
 config COMEDI_DT3000
        tristate "Data Translation DT3000 series support"
        default N
@@ -1390,20 +1414,6 @@ config COMEDI_8255
          To compile this driver as a module, choose M here: the module will be
          called 8255.
 
-config COMEDI_DAS08
-       tristate "DAS-08 compatible support"
-       depends on COMEDI
-       select COMEDI_8255
-       default N
-       ---help---
-         Enable support for DAS08 and compatible ISA, PC/104 and PCI cards.
-
-         Note that PCMCIA DAS08 cards are not directly supported by this
-         driver, and need a separate driver as a wrapper.
-
-         To compile this driver as a module, choose M here: the module will be
-         called das08.
-
 config COMEDI_FC
        tristate "Comedi shared functions for low-level driver support"
        depends on COMEDI
@@ -1429,3 +1439,8 @@ config COMEDI_AMPLC_PC236
 config COMEDI_AMPLC_PC263
        def_tristate N
        depends on COMEDI
+
+config COMEDI_DAS08
+       def_tristate N
+       depends on COMEDI
+       select COMEDI_8255
index c2dd0ed36a73d56a87ab20c10597257f77865a7e..05a8d0cf3758b4b263141cfa72c9f8fb80ca3b0c 100644 (file)
 
 #define DRV_NAME "das08"
 
+#ifdef CONFIG_COMEDI_DAS08_ISA_MODULE
+#define CONFIG_COMEDI_DAS08_ISA
+#endif
+#ifdef CONFIG_COMEDI_DAS08_PCI_MODULE
+#define CONFIG_COMEDI_DAS08_PCI
+#endif
+#ifdef CONFIG_COMEDI_DAS08_CS_MODULE
+#define CONFIG_COMEDI_DAS08_CS
+#endif
+
+#if defined(CONFIG_COMEDI_DAS08_ISA) || defined(CONFIG_COMEDI_DAS08_PCI)
+#define DO_COMEDI_DRIVER_REGISTER
+#endif
+
 #define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307
 #define PCI_DEVICE_ID_PCIDAS08 0x29
 #define PCIDAS08_SIZE 0x54
@@ -160,6 +174,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
                          struct comedi_insn *insn, unsigned int *data);
 static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
                          struct comedi_insn *insn, unsigned int *data);
+#ifdef CONFIG_COMEDI_DAS08_ISA
 static int das08jr_di_rbits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data);
@@ -172,6 +187,7 @@ static int das08jr_ao_winsn(struct comedi_device *dev,
 static int das08ao_ao_winsn(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data);
+#endif
 static void i8254_set_mode_low(unsigned int base, int channel,
                               unsigned int mode);
 
@@ -253,7 +269,9 @@ static const int *const das08_gainlists[] = {
        das08_pgm_gainlist,
 };
 
+#ifdef DO_COMEDI_DRIVER_REGISTER
 static const struct das08_board_struct das08_boards[] = {
+#ifdef CONFIG_COMEDI_DAS08_ISA
        {
         .name = "isa-das08",   /*  cio-das08.pdf */
         .bustype = isa,
@@ -395,25 +413,6 @@ static const struct das08_board_struct das08_boards[] = {
         .i8254_offset = 0x04,
         .iosize = 16,          /*  unchecked */
         },
-#ifdef CONFIG_COMEDI_PCI
-       {
-        .name = "das08",       /*  pci-das08 */
-        .id = PCI_DEVICE_ID_PCIDAS08,
-        .bustype = pci,
-        .ai = das08_ai_rinsn,
-        .ai_nbits = 12,
-        .ai_pg = das08_bipolar5,
-        .ai_encoding = das08_encode12,
-        .ao = NULL,
-        .ao_nbits = 0,
-        .di = das08_di_rbits,
-        .do_ = das08_do_wbits,
-        .do_nchan = 4,
-        .i8255_offset = 0,
-        .i8254_offset = 4,
-        .iosize = 8,
-        },
-#endif
        {
         .name = "pc104-das08",
         .bustype = pc104,
@@ -462,9 +461,30 @@ static const struct das08_board_struct das08_boards[] = {
         .name = "das08-pga-g2",        /*  a KM board */
         },
 #endif
+#endif /* CONFIG_COMEDI_DAS08_ISA */
+#ifdef CONFIG_COMEDI_DAS08_PCI
+       {
+        .name = "das08",       /*  pci-das08 */
+        .id = PCI_DEVICE_ID_PCIDAS08,
+        .bustype = pci,
+        .ai = das08_ai_rinsn,
+        .ai_nbits = 12,
+        .ai_pg = das08_bipolar5,
+        .ai_encoding = das08_encode12,
+        .ao = NULL,
+        .ao_nbits = 0,
+        .di = das08_di_rbits,
+        .do_ = das08_do_wbits,
+        .do_nchan = 4,
+        .i8255_offset = 0,
+        .i8254_offset = 4,
+        .iosize = 8,
+        },
+#endif /* CONFIG_COMEDI_DAS08_PCI */
 };
+#endif /* DO_COMEDI_DRIVER_REGISTER */
 
-#ifdef CONFIG_COMEDI_PCMCIA
+#ifdef CONFIG_COMEDI_DAS08_CS
 struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
        {
         .name = "pcm-das08",
@@ -504,7 +524,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
 };
 #endif
 
-#ifdef CONFIG_COMEDI_PCI
+#ifdef CONFIG_COMEDI_DAS08_PCI
 static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08) },
        {0}
@@ -619,6 +639,7 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
        return 2;
 }
 
+#ifdef CONFIG_COMEDI_DAS08_ISA
 static int das08jr_di_rbits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
@@ -628,7 +649,9 @@ static int das08jr_di_rbits(struct comedi_device *dev,
 
        return 2;
 }
+#endif
 
+#ifdef CONFIG_COMEDI_DAS08_ISA
 static int das08jr_do_wbits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
@@ -643,7 +666,9 @@ static int das08jr_do_wbits(struct comedi_device *dev,
 
        return 2;
 }
+#endif
 
+#ifdef CONFIG_COMEDI_DAS08_ISA
 static int das08jr_ao_winsn(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
@@ -672,6 +697,7 @@ static int das08jr_ao_winsn(struct comedi_device *dev,
 
        return n;
 }
+#endif
 
 /*
  *
@@ -679,6 +705,7 @@ static int das08jr_ao_winsn(struct comedi_device *dev,
  * a different method to force an update.
  *
  */
+#ifdef CONFIG_COMEDI_DAS08_ISA
 static int das08ao_ao_winsn(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
@@ -707,6 +734,7 @@ static int das08ao_ao_winsn(struct comedi_device *dev,
 
        return n;
 }
+#endif
 
 static unsigned int i8254_read_channel_low(unsigned int base, int chan)
 {
@@ -842,6 +870,7 @@ static int das08_counter_config(struct comedi_device *dev,
        return 2;
 }
 
+#ifdef DO_COMEDI_DRIVER_REGISTER
 static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 
 static struct comedi_driver driver_das08 = {
@@ -853,6 +882,7 @@ static struct comedi_driver driver_das08 = {
        .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct),
        .offset = sizeof(struct das08_board_struct),
 };
+#endif
 
 int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 {
@@ -972,11 +1002,12 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 }
 EXPORT_SYMBOL_GPL(das08_common_attach);
 
+#ifdef DO_COMEDI_DRIVER_REGISTER
 static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        int ret;
        unsigned long iobase;
-#ifdef CONFIG_COMEDI_PCI
+#ifdef CONFIG_COMEDI_DAS08_PCI
        unsigned long pci_iobase = 0;
        struct pci_dev *pdev = NULL;
 #endif
@@ -986,9 +1017,9 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return ret;
 
        printk(KERN_INFO "comedi%d: das08: ", dev->minor);
+#ifdef CONFIG_COMEDI_DAS08_PCI
        /*  deal with a pci board */
        if (thisboard->bustype == pci) {
-#ifdef CONFIG_COMEDI_PCI
                if (it->options[0] || it->options[1]) {
                        printk("bus %i slot %i ",
                               it->options[0], it->options[1]);
@@ -1037,17 +1068,16 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                /* Enable local interrupt 1 and pci interrupt */
                outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
 #endif
-#else /* CONFIG_COMEDI_PCI */
-               printk(KERN_ERR "this driver has not been built with PCI support.\n");
-               return -EINVAL;
-#endif /* CONFIG_COMEDI_PCI */
-       } else {
+       } else
+#endif /* CONFIG_COMEDI_DAS08_PCI */
+       {
                iobase = it->options[0];
        }
        printk(KERN_INFO "\n");
 
        return das08_common_attach(dev, iobase);
 }
+#endif /* DO_COMEDI_DRIVER_REGISTER */
 
 
 int das08_common_detach(struct comedi_device *dev)
@@ -1062,7 +1092,7 @@ int das08_common_detach(struct comedi_device *dev)
                if (dev->iobase)
                        release_region(dev->iobase, thisboard->iosize);
        }
-#ifdef CONFIG_COMEDI_PCI
+#ifdef CONFIG_COMEDI_DAS08_PCI
        if (devpriv) {
                if (devpriv->pdev) {
                        if (devpriv->pci_iobase)
@@ -1077,7 +1107,7 @@ int das08_common_detach(struct comedi_device *dev)
 }
 EXPORT_SYMBOL_GPL(das08_common_detach);
 
-#ifdef CONFIG_COMEDI_PCI
+#ifdef CONFIG_COMEDI_DAS08_PCI
 static int __devinit driver_das08_pci_probe(struct pci_dev *dev,
                                            const struct pci_device_id *ent)
 {
@@ -1094,43 +1124,38 @@ static struct pci_driver driver_das08_pci_driver = {
        .probe = &driver_das08_pci_probe,
        .remove = __devexit_p(&driver_das08_pci_remove)
 };
+#endif /* CONFIG_COMEDI_DAS08_PCI */
 
 static int __init driver_das08_init_module(void)
 {
-       int retval;
+       int retval = 0;
 
+#ifdef DO_COMEDI_DRIVER_REGISTER
        retval = comedi_driver_register(&driver_das08);
        if (retval < 0)
                return retval;
-
+#endif
+#ifdef CONFIG_COMEDI_DAS08_PCI
        driver_das08_pci_driver.name = (char *)driver_das08.driver_name;
-       return pci_register_driver(&driver_das08_pci_driver);
+       retval = pci_register_driver(&driver_das08_pci_driver);
+#endif
+       return retval;
 }
 
 static void __exit driver_das08_cleanup_module(void)
 {
+#ifdef CONFIG_COMEDI_DAS08_PCI
        pci_unregister_driver(&driver_das08_pci_driver);
+#endif
+#ifdef DO_COMEDI_DRIVER_REGISTER
        comedi_driver_unregister(&driver_das08);
+#endif
 }
 
 module_init(driver_das08_init_module);
 module_exit(driver_das08_cleanup_module);
-#else
-static int __init driver_das08_init_module(void)
-{
-       return comedi_driver_register(&driver_das08);
-}
-
-static void __exit driver_das08_cleanup_module(void)
-{
-       comedi_driver_unregister(&driver_das08);
-}
-
-module_init(driver_das08_init_module);
-module_exit(driver_das08_cleanup_module);
-#endif
 
-#ifdef CONFIG_COMEDI_PCMCIA
+#ifdef CONFIG_COMEDI_DAS08_CS
 EXPORT_SYMBOL_GPL(das08_cs_boards);
 #endif