Fixed some of the pci drivers that didn't accept the driver name
authorFrank Mori Hess <fmhess@speakeasy.net>
Tue, 21 Oct 2008 20:46:33 +0000 (20:46 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Tue, 21 Oct 2008 20:46:33 +0000 (20:46 +0000)
as board name when running comedi_config.

comedi/drivers/adl_pci7296.c
comedi/drivers/adl_pci7432.c
comedi/drivers/adl_pci8164.c
comedi/drivers/adl_pci9111.c
comedi/drivers/adv_pci1710.c
comedi/drivers/adv_pci1723.c
comedi/drivers/das08.c
comedi/drivers/me_daq.c
comedi/drivers/ni_labpc.c

index 1f80b648e52045f4ad5ff2058cf62e494ce8d113..73df5ee43f503cd30fc165b98e9e5316cc3ea7bb 100644 (file)
@@ -22,7 +22,7 @@
 /*
 Driver: adl_pci7296
 Description: Driver for the Adlink PCI-7296 96 ch. digital io board
-Devices: [ADLink] PCI-7296 (pci7296)
+Devices: [ADLink] PCI-7296 (adl_pci7296)
 Author: Jon Grierson <jd@renko.co.uk>
 Updated: Mon, 14 Apr 2008 15:05:56 +0100
 Status: testing
@@ -48,16 +48,6 @@ Configuration Options:
 
 #define PCI_DEVICE_ID_PCI7296 0x7296
 
-typedef struct skel_board_struct {
-       const char *name;
-       int vendor_id;
-       int device_id;
-} adl_pci7296_board;
-
-static const adl_pci7296_board adl_pci7296_boards[] = {
-       {"pci7296", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296},
-};
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
        {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, PCI_ANY_ID, 0,
                0, 0},
@@ -66,8 +56,6 @@ static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
 
 MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
 
-#define thisboard ((const adl_pci7296_board *)dev->board_ptr)
-
 typedef struct {
        int data;
        struct pci_dev *pci_dev;
@@ -82,10 +70,6 @@ static comedi_driver driver_adl_pci7296 = {
       module:THIS_MODULE,
       attach:adl_pci7296_attach,
       detach:adl_pci7296_detach,
-
-      board_name:&adl_pci7296_boards[0].name,
-      offset:sizeof(adl_pci7296_board),
-      num_names:sizeof(adl_pci7296_boards) / sizeof(adl_pci7296_board),
 };
 
 static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it)
@@ -96,10 +80,9 @@ static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it)
        int ret;
 
        printk("comedi: attempt to attach...\n");
-       printk("comedi%d: adl_pci7432: board=%s\n", dev->minor,
-               thisboard->name);
+       printk("comedi%d: adl_pci7432\n", dev->minor);
 
-       dev->board_name = thisboard->name;
+       dev->board_name = "pci7432";
        bus = it->options[0];
        slot = it->options[1];
 
@@ -131,8 +114,6 @@ static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it)
                        dev->iobase = pci_resource_start(pcidev, 2);
                        printk("comedi: base addr %4lx\n", dev->iobase);
 
-                       dev->board_ptr = adl_pci7296_boards + 0;
-
                        // four 8255 digital io subdevices
                        s = dev->subdevices + 0;
                        subdev_8255_init(dev, s, NULL,
index 6bda91b477227dada0c88d9c4990017580f2300f..74dd68c3353e78653b361418beecb623c16119f4 100644 (file)
@@ -22,7 +22,7 @@
 /*
 Driver: adl_pci7432
 Description: Driver for the Adlink PCI-7432 64 ch. isolated digital io board
-Devices: [ADLink] PCI-7432 (pci7432)
+Devices: [ADLink] PCI-7432 (adl_pci7432)
 Author: Michel Lachaine <mike@mikelachaine.ca>
 Status: experimental
 Updated: Mon, 14 Apr 2008 15:08:14 +0100
@@ -43,16 +43,6 @@ Configuration Options:
 
 #define PCI_DEVICE_ID_PCI7432 0x7432
 
-typedef struct {
-       const char *name;
-       int vendor_id;
-       int device_id;
-} adl_pci7432_board;
-
-static const adl_pci7432_board adl_pci7432_boards[] = {
-       {"pci7432", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432},
-};
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
        {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, PCI_ANY_ID, 0,
                0, 0},
@@ -61,8 +51,6 @@ static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
 
 MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
 
-#define thisboard ((const adl_pci7432_board *)dev->board_ptr)
-
 typedef struct {
        int data;
        struct pci_dev *pci_dev;
@@ -77,9 +65,6 @@ static comedi_driver driver_adl_pci7432 = {
       module:THIS_MODULE,
       attach:adl_pci7432_attach,
       detach:adl_pci7432_detach,
-      num_names:1,
-      board_name:&adl_pci7432_boards[0].name,
-      offset:sizeof(adl_pci7432_board),
 };
 
 /* Digital IO */
@@ -99,10 +84,9 @@ static int adl_pci7432_attach(comedi_device * dev, comedi_devconfig * it)
        int bus, slot;
 
        printk("comedi: attempt to attach...\n");
-       printk("comedi%d: adl_pci7432: board=%s\n", dev->minor,
-               thisboard->name);
+       printk("comedi%d: adl_pci7432\n", dev->minor);
 
-       dev->board_name = thisboard->name;
+       dev->board_name = "pci7432";
        bus = it->options[0];
        slot = it->options[1];
 
@@ -133,8 +117,6 @@ static int adl_pci7432_attach(comedi_device * dev, comedi_devconfig * it)
                        dev->iobase = pci_resource_start(pcidev, 2);
                        printk("comedi: base addr %4lx\n", dev->iobase);
 
-                       dev->board_ptr = adl_pci7432_boards + 0;
-
                        s = dev->subdevices + 0;
                        s->type = COMEDI_SUBD_DI;
                        s->subdev_flags =
index 8c22b7fa2525da1ca2b3d8c4cf73db30df3cb094..dd84f3ab4c4f19135d23c8235bfde6409ac86621 100644 (file)
@@ -22,7 +22,7 @@
 /*
 Driver: adl_pci8164
 Description: Driver for the Adlink PCI-8164 4 Axes Motion Control board
-Devices: [ADLink] PCI-8164 (pci8164)
+Devices: [ADLink] PCI-8164 (adl_pci8164)
 Author: Michel Lachaine <mike@mikelachaine.ca>
 Status: experimental
 Updated: Mon, 14 Apr 2008 15:10:32 +0100
@@ -55,16 +55,6 @@ Configuration Options:
 
 #define PCI_DEVICE_ID_PCI8164 0x8164
 
-typedef struct {
-       const char *name;
-       int vendor_id;
-       int device_id;
-} adl_pci8164_board;
-
-static const adl_pci8164_board adl_pci8164_boards[] = {
-       {"pci8164", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164},
-};
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
        {PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, PCI_ANY_ID, 0,
                0, 0},
@@ -73,8 +63,6 @@ static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
 
 MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
 
-#define thisboard ((const adl_pci8164_board *)dev->board_ptr)
-
 typedef struct {
        int data;
        struct pci_dev *pci_dev;
@@ -89,9 +77,6 @@ static comedi_driver driver_adl_pci8164 = {
       module:THIS_MODULE,
       attach:adl_pci8164_attach,
       detach:adl_pci8164_detach,
-      num_names:1,
-      board_name:&adl_pci8164_boards[0].name,
-      offset:sizeof(adl_pci8164_board),
 };
 
 static int adl_pci8164_insn_read_msts(comedi_device * dev, comedi_subdevice * s,
@@ -125,10 +110,9 @@ static int adl_pci8164_attach(comedi_device * dev, comedi_devconfig * it)
        int bus, slot;
 
        printk("comedi: attempt to attach...\n");
-       printk("comedi%d: adl_pci8164: board=%s\n", dev->minor,
-               thisboard->name);
+       printk("comedi%d: adl_pci8164\n", dev->minor);
 
-       dev->board_name = thisboard->name;
+       dev->board_name = "pci8164";
        bus = it->options[0];
        slot = it->options[1];
 
@@ -159,8 +143,6 @@ static int adl_pci8164_attach(comedi_device * dev, comedi_devconfig * it)
                        dev->iobase = pci_resource_start(pcidev, 2);
                        printk("comedi: base addr %4lx\n", dev->iobase);
 
-                       dev->board_ptr = adl_pci8164_boards + 0;
-
                        s = dev->subdevices + 0;
                        s->type = COMEDI_SUBD_PROC;
                        s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
index b55d52da47428274ce15c55a0a1b7f369e246400..2bc370c406311f56fc3d597a87086630ad60296b 100644 (file)
@@ -331,9 +331,6 @@ static comedi_driver pci9111_driver = {
       module:THIS_MODULE,
       attach:pci9111_attach,
       detach:pci9111_detach,
-      num_names:pci9111_board_nbr,
-      board_name:&pci9111_boards[0].name,
-      offset:sizeof(pci9111_board_struct),
 };
 
 COMEDI_PCI_INITCLEANUP(pci9111_driver, pci9111_pci_table);
index 17b0257556f2342542f5262a26e7b0d21bcc6ed7..65e1d23ea7031b047813f3ee49d35f937422b81d 100644 (file)
@@ -21,9 +21,9 @@ Driver: adv_pci1710
 Description: Advantech PCI-1710, PCI-1710HG, PCI-1711, PCI-1713,
              Advantech PCI-1720, PCI-1731
 Author: Michal Dobes <dobes@tesnet.cz>
-Devices: [Advantech] PCI-1710 (pci1710), PCI-1710HG (pci1710hg),
-  PCI-1711 (pci1711), PCI-1713 (pci1713), PCI-1720 (pci1720),
-  PCI-1731 (pci1731)
+Devices: [Advantech] PCI-1710 (adv_pci1710), PCI-1710HG (pci1710hg),
+  PCI-1711 (adv_pci1710), PCI-1713, PCI-1720,
+  PCI-1731
 Status: works
 
 This driver supports AI, AO, DI and DO subdevices.
@@ -52,6 +52,8 @@ Configuration options:
 
 #undef PCI171X_EXTDEBUG
 
+#define DRV_NAME "adv_pci1710"
+
 #undef DPRINTK
 #ifdef PCI171X_EXTDEBUG
 #define DPRINTK(fmt, args...) rt_printk(fmt, ## args)
@@ -217,49 +219,51 @@ MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
 
 static const boardtype boardtypes[] = {
        {"pci1710", 0x1710,
-                       IORANGE_171x, 1, TYPE_PCI171X,
-                       16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
-                       &range_pci1710_3, range_codes_pci1710_3,
-                       &range_pci171x_da,
+               IORANGE_171x, 1, TYPE_PCI171X,
+               16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+               &range_pci1710_3, range_codes_pci1710_3,
+               &range_pci171x_da,
                10000, 2048},
        {"pci1710hg", 0x1710,
-                       IORANGE_171x, 1, TYPE_PCI171X,
-                       16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
-                       &range_pci1710hg, range_codes_pci1710hg,
-                       &range_pci171x_da,
+               IORANGE_171x, 1, TYPE_PCI171X,
+               16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+               &range_pci1710hg, range_codes_pci1710hg,
+               &range_pci171x_da,
                10000, 2048},
        {"pci1711", 0x1711,
-                       IORANGE_171x, 1, TYPE_PCI171X,
-                       16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
-                       &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
+               IORANGE_171x, 1, TYPE_PCI171X,
+               16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
+               &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
                10000, 512},
        {"pci1713", 0x1713,
-                       IORANGE_171x, 1, TYPE_PCI1713,
-                       32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
-                       &range_pci1710_3, range_codes_pci1710_3, NULL,
+               IORANGE_171x, 1, TYPE_PCI1713,
+               32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
+               &range_pci1710_3, range_codes_pci1710_3, NULL,
                10000, 2048},
        {"pci1720", 0x1720,
-                       IORANGE_1720, 0, TYPE_PCI1720,
-                       0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
-                       NULL, NULL, &range_pci1720,
+               IORANGE_1720, 0, TYPE_PCI1720,
+               0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
+               NULL, NULL, &range_pci1720,
                0, 0},
        {"pci1731", 0x1731,
-                       IORANGE_171x, 1, TYPE_PCI171X,
-                       16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
-                       &range_pci17x1, range_codes_pci17x1, NULL,
+               IORANGE_171x, 1, TYPE_PCI171X,
+               16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
+               &range_pci17x1, range_codes_pci17x1, NULL,
                10000, 512},
+       // dummy entry corresponding to driver name
+       {.name = DRV_NAME},
 };
 
 #define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
 
 static comedi_driver driver_pci1710 = {
-      driver_name:"adv_pci1710",
-      module:THIS_MODULE,
-      attach:pci1710_attach,
-      detach:pci1710_detach,
-      num_names:n_boardtypes,
-      board_name:&boardtypes[0].name,
-      offset:sizeof(boardtype),
+       .driver_name = DRV_NAME,
+       .module = THIS_MODULE,
+       .attach = pci1710_attach,
+       .detach = pci1710_detach,
+       .num_names = n_boardtypes,
+       .board_name = &boardtypes[0].name,
+       .offset = sizeof(boardtype),
 };
 
 typedef struct {
@@ -1322,9 +1326,10 @@ static int pci1710_attach(comedi_device * dev, comedi_devconfig * it)
        int opt_bus, opt_slot;
        const char *errstr;
        unsigned char pci_bus, pci_slot, pci_func;
+       int i;
+       int board_index;
 
-       rt_printk("comedi%d: adv_pci1710: board=%s", dev->minor,
-               this_board->name);
+       rt_printk("comedi%d: adv_pci1710: ", dev->minor);
 
        opt_bus = it->options[0];
        opt_slot = it->options[1];
@@ -1337,8 +1342,25 @@ static int pci1710_attach(comedi_device * dev, comedi_devconfig * it)
        /* Look for matching PCI device */
        errstr = "not found!";
        pcidev = NULL;
+       board_index = this_board - boardtypes;
        while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
-                               this_board->device_id, pcidev))) {
+               PCI_ANY_ID, pcidev))) {
+               if(strcmp(this_board->name, DRV_NAME) == 0)
+               {
+                       for(i = 0; i < n_boardtypes; ++i)
+                       {
+                               if(pcidev->device == boardtypes[i].device_id)
+                               {
+                                       board_index = i;
+                                       break;
+                               }
+                       }
+                       if(i == n_boardtypes) continue;
+               }else
+               {
+                       if(pcidev->device != boardtypes[board_index].device_id) continue;
+               }
+
                /* Found matching vendor/device. */
                if (opt_bus || opt_slot) {
                        /* Check bus/slot. */
@@ -1347,13 +1369,15 @@ static int pci1710_attach(comedi_device * dev, comedi_devconfig * it)
                                continue;       /* no match */
                }
                /*
-                * Look for device that isn't in use.
-                * Enable PCI device and request regions.
-                */
-               if (comedi_pci_enable(pcidev, "adv_pci1710")) {
+               * Look for device that isn't in use.
+               * Enable PCI device and request regions.
+               */
+               if (comedi_pci_enable(pcidev, DRV_NAME)) {
                        errstr = "failed to enable PCI device and request regions!";
                        continue;
                }
+               // fixup board_ptr in case we were using the dummy entry with the driver name
+               dev->board_ptr = &boardtypes[board_index];
                break;
        }
 
index 2f4506acff04fd74705d86fa220ad91b817b3b44..037cfb61af5a6b0ee216ece21ffb7c24c7e9bb26 100644 (file)
@@ -23,7 +23,7 @@
 Driver: adv_pci1723
 Description: Advantech PCI-1723
 Author: yonggang <rsmgnu@gmail.com>, Ian Abbott <abbotti@mev.co.uk>
-Devices: [Advantech] PCI-1723 (pci1723)
+Devices: [Advantech] PCI-1723 (adv_pci1723)
 Updated: Mon, 14 Apr 2008 15:12:56 +0100
 Status: works
 
@@ -153,9 +153,6 @@ static comedi_driver driver_pci1723 = {
       module:THIS_MODULE,
       attach:pci1723_attach,
       detach:pci1723_detach,
-      num_names:n_boardtypes,
-      board_name:&boardtypes[0].name,
-      offset:sizeof(boardtype),
 };
 
 /* this structure is for data unique to this hardware driver. */
@@ -173,7 +170,7 @@ typedef struct {
 */
 #define devpriv ((pci1723_private *)dev->private)
 
-#define this_board ((const boardtype *)dev->board_ptr)
+#define this_board boardtypes
 
 /*
  *   the pci1723 card reset;
index 3a186184ab63ca32c73b5a160815bdc98b362e1e..a8f15abc96f7397b7986bc36a3a9e75fb47a7053 100644 (file)
 Driver: das08
 Description: DAS-08 compatible boards
 Author: Warren Jasper, ds, Frank Hess
-Devices: [Keithley Metrabyte] DAS08 (das08), [ComputerBoards] DAS08 (das08),
+Devices: [Keithley Metrabyte] DAS08 (isa-das08), [ComputerBoards] DAS08 (isa-das08),
   DAS08-PGM (das08-pgm),
   DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh),
   DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao),
-  DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (pci-das08),
+  DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08),
   PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16)
 Status: works
 
@@ -44,7 +44,6 @@ Options (for ISA cards):
 Options (for pci-das08):
         [0] - bus  (optional)
         [1] = slot (optional)
-Use the name 'pci-das08' for the pci-das08, NOT 'das08'.
 
 The das08 driver doesn't support asynchronous commands, since
 the cheap das08 hardware doesn't really support them.  The
@@ -60,6 +59,8 @@ driver.
 #include "8255.h"
 #include "das08.h"
 
+#define DRV_NAME "das08"
+
 #define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307
 #define PCI_DEVICE_ID_PCIDAS08 0x29
 #define PCIDAS08_SIZE 0x54
@@ -77,7 +78,7 @@ driver.
 /*
     cio-das08.pdf
 
-  "das08"
+  "isa-das08"
 
   0    a/d bits 0-3            start 8 bit
   1    a/d bits 4-11           start 12 bit
@@ -247,7 +248,7 @@ static const int *const das08_gainlists[] = {
 
 static const struct das08_board_struct das08_boards[] = {
        {
-             name:     "das08",        // cio-das08.pdf
+             name:     "isa-das08",    // cio-das08.pdf
              bustype:  isa,
              ai:       das08_ai_rinsn,
              ai_nbits:12,
@@ -388,7 +389,7 @@ static const struct das08_board_struct das08_boards[] = {
              iosize:   16,     // unchecked
                },
        {
-             name:     "pci-das08",
+             name:     "das08",        // pci-das08
              id:       PCI_DEVICE_ID_PCIDAS08,
              bustype:  pci,
              ai:       das08_ai_rinsn,
@@ -823,7 +824,7 @@ static int das08_counter_config(comedi_device * dev, comedi_subdevice * s,
 static int das08_attach(comedi_device * dev, comedi_devconfig * it);
 
 static comedi_driver driver_das08 = {
-      driver_name:"das08",
+      driver_name: DRV_NAME,
       module:THIS_MODULE,
       attach:das08_attach,
       detach:das08_common_detach,
@@ -841,7 +842,7 @@ int das08_common_attach(comedi_device * dev, unsigned long iobase)
        // allocate ioports for non-pcmcia, non-pci boards
        if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
                printk(" iobase 0x%lx\n", iobase);
-               if (!request_region(iobase, thisboard->iosize, "das08")) {
+               if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
                        printk(" I/O port conflict\n");
                        return -EIO;
                }
@@ -985,7 +986,7 @@ static int das08_attach(comedi_device * dev, comedi_devconfig * it)
                }
                devpriv->pdev = pdev;
                // enable PCI device and reserve I/O spaces
-               if (comedi_pci_enable(pdev, "das08")) {
+               if (comedi_pci_enable(pdev, DRV_NAME)) {
                        printk(" Error enabling PCI device and requesting regions\n");
                        return -EIO;
                }
index 630fd8910f9f3000bab5d26bff3566153c5bf1ce..cccf38d872511d1c50ee793636fb1f7d853bdc59 100644 (file)
@@ -253,9 +253,6 @@ static comedi_driver me_driver = {
       module:THIS_MODULE,
       attach:me_attach,
       detach:me_detach,
-      num_names:me_board_nbr,
-      board_name:&me_boards[0].name,
-      offset:sizeof(me_board_struct),
 };
 
 COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table);
index cc58ca585aa759153197c8014a9705657a12a22c..901fc7bbfc53140e084e5e8f56a4c5ee61864c5a 100644 (file)
@@ -24,7 +24,7 @@ Driver: ni_labpc
 Description: National Instruments Lab-PC (& compatibles)
 Author: Frank Mori Hess <fmhess@users.sourceforge.net>
 Devices: [National Instruments] Lab-PC-1200 (labpc-1200),
-  Lab-PC-1200AI (labpc-1200ai), Lab-PC+ (lab-pc+), PCI-1200 (pci-1200)
+  Lab-PC-1200AI (labpc-1200ai), Lab-PC+ (lab-pc+), PCI-1200 (ni_labpc)
 Status: works
 
 Tested with lab-pc-1200.  For the older Lab-PC+, not all input ranges
@@ -87,6 +87,8 @@ NI manuals:
 #include "comedi_fc.h"
 #include "ni_labpc.h"
 
+#define DRV_NAME "ni_labpc"
+
 #define LABPC_SIZE           32        // size of io region used by board
 #define LABPC_TIMER_BASE            500        // 2 MHz master clock
 
@@ -188,7 +190,7 @@ static int labpc_eeprom_write_insn(comedi_device * dev, comedi_subdevice * s,
 static unsigned int labpc_suggest_transfer_size(comedi_cmd cmd);
 static void labpc_adc_timing(comedi_device * dev, comedi_cmd * cmd);
 #ifdef CONFIG_COMEDI_PCI
-static struct mite_struct *labpc_find_device(int bus, int slot);
+static int labpc_find_device(comedi_device *dev, int bus, int slot);
 #endif
 static int labpc_dio_mem_callback(int dir, int port, int data,
        unsigned long arg);
@@ -397,17 +399,22 @@ static const labpc_board labpc_boards[] = {
                },
 #ifdef CONFIG_COMEDI_PCI
        {
-             name:     "pci-1200",
-             device_id:0x161,
-             ai_speed:10000,
-             bustype:  pci_bustype,
-             register_layout:labpc_1200_layout,
-             has_ao:   1,
-             ai_range_table:&range_labpc_1200_ai,
-             ai_range_code:labpc_1200_ai_gain_bits,
-             ai_range_is_unipolar:labpc_1200_is_unipolar,
-             ai_scan_up:1,
-             memory_mapped_io:1,
+               name:   "pci-1200",
+               device_id:0x161,
+               ai_speed:10000,
+               bustype:        pci_bustype,
+               register_layout:labpc_1200_layout,
+               has_ao: 1,
+               ai_range_table:&range_labpc_1200_ai,
+               ai_range_code:labpc_1200_ai_gain_bits,
+               ai_range_is_unipolar:labpc_1200_is_unipolar,
+               ai_scan_up:1,
+               memory_mapped_io:1,
+               },
+       // dummy entry so pci board works when comedi_config is passed driver name
+       {
+               .name = DRV_NAME,
+               .bustype = pci_bustype,
                },
 #endif
 };
@@ -423,13 +430,13 @@ static const int sample_size = 2; // 2 bytes per sample
 #define devpriv ((labpc_private *)dev->private)
 
 static comedi_driver driver_labpc = {
-      driver_name:"ni_labpc",
-      module:THIS_MODULE,
-      attach:labpc_attach,
-      detach:labpc_common_detach,
-      num_names:sizeof(labpc_boards) / sizeof(labpc_board),
-      board_name:&labpc_boards[0].name,
-      offset:sizeof(labpc_board),
+       .driver_name = DRV_NAME,
+       .module = THIS_MODULE,
+       .attach = labpc_attach,
+       .detach = labpc_common_detach,
+       .num_names = sizeof(labpc_boards) / sizeof(labpc_board),
+       .board_name = &labpc_boards[0].name,
+       .offset = sizeof(labpc_board),
 };
 
 #ifdef CONFIG_COMEDI_PCI
@@ -641,6 +648,7 @@ static int labpc_attach(comedi_device * dev, comedi_devconfig * it)
        unsigned long iobase = 0;
        unsigned int irq = 0;
        unsigned int dma_chan = 0;
+       int retval;
 
        /* allocate and initialize dev->private */
        if (alloc_private(dev, sizeof(labpc_private)) < 0)
@@ -655,20 +663,13 @@ static int labpc_attach(comedi_device * dev, comedi_devconfig * it)
                break;
        case pci_bustype:
 #ifdef CONFIG_COMEDI_PCI
-               devpriv->mite =
-                       labpc_find_device(it->options[0], it->options[1]);
-               if (devpriv->mite == NULL) {
-                       return -EIO;
-               }
-               if (thisboard->device_id != mite_device_id(devpriv->mite)) {    // this should never happen since this driver only supports one type of pci board
-                       printk("bug! mite device id does not match boardtype definition\n");
-                       return -EINVAL;
-               }
-               {
-                       int ret = mite_setup(devpriv->mite);
-                       if (ret < 0)
-                               return ret;
+               retval = labpc_find_device(dev, it->options[0], it->options[1]);
+               if (retval < 0) {
+                       return retval;
                }
+               retval = mite_setup(devpriv->mite);
+               if (retval < 0)
+                       return retval;
                iobase = (unsigned long)devpriv->mite->daq_io_addr;
                irq = mite_irq(devpriv->mite);
 #else
@@ -691,7 +692,7 @@ static int labpc_attach(comedi_device * dev, comedi_devconfig * it)
 
 // adapted from ni_pcimio for finding mite based boards (pc-1200)
 #ifdef CONFIG_COMEDI_PCI
-static struct mite_struct *labpc_find_device(int bus, int slot)
+static int labpc_find_device(comedi_device *dev, int bus, int slot)
 {
        struct mite_struct *mite;
        int i;
@@ -708,13 +709,16 @@ static struct mite_struct *labpc_find_device(int bus, int slot)
                        if (labpc_boards[i].bustype != pci_bustype)
                                continue;
                        if (mite_device_id(mite) == labpc_boards[i].device_id) {
-                               return mite;
+                               devpriv->mite = mite;
+                               // fixup board pointer, in case we were using the dummy "ni_labpc" entry
+                               dev->board_ptr = &labpc_boards[i];
+                               return 0;
                        }
                }
        }
        printk("no device found\n");
        mite_list_devices();
-       return NULL;
+       return -EIO;
 }
 #endif