staging: comedi: addi_apci_1516: cleanup addi_find_boardinfo()
authorH Hartley Sweeten <hartleys@visionengravers.com>
Tue, 13 Nov 2012 20:44:36 +0000 (13:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2012 23:12:53 +0000 (15:12 -0800)
This driver uses the comedi auto_config mechanism to attach to the
PCI board.

This mechanism does not require passing the boardinfo data in the
comedi_driver. Remove it and modify the code to directly access
the boardinfo data instead of messing with the dev->driver->board_name
pointer.

All the boards supported by this driver have the same PCI vendor id.
Remove this extra info from the boardinfo and the test for it.

Rename the function so it has namespace associated with this driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_1516.c

index 36ae5cda3891b40c5c94da84bf0c442d7865b608..e2d79c3b2d926d1f3332f42cd3038ccebd427867 100644 (file)
@@ -9,7 +9,6 @@ struct apci1516_private {
 
 struct apci1516_boardinfo {
        const char *name;
-       unsigned short vendor;
        unsigned short device;
        int di_nchan;
        int do_nchan;
@@ -19,19 +18,16 @@ struct apci1516_boardinfo {
 static const struct apci1516_boardinfo apci1516_boardtypes[] = {
        {
                .name           = "apci1016",
-               .vendor         = PCI_VENDOR_ID_ADDIDATA,
                .device         = 0x1000,
                .di_nchan       = 16,
        }, {
                .name           = "apci1516",
-               .vendor         = PCI_VENDOR_ID_ADDIDATA,
                .device         = 0x1001,
                .di_nchan       = 8,
                .do_nchan       = 8,
                .has_timer      = 1,
        }, {
                .name           = "apci2016",
-               .vendor         = PCI_VENDOR_ID_ADDIDATA,
                .device         = 0x1002,
                .do_nchan       = 16,
                .has_timer      = 1,
@@ -54,19 +50,16 @@ static int apci1516_reset(struct comedi_device *dev)
        return 0;
 }
 
-static const void *addi_find_boardinfo(struct comedi_device *dev,
-                                      struct pci_dev *pcidev)
+static const void *apci1516_find_boardinfo(struct comedi_device *dev,
+                                          struct pci_dev *pcidev)
 {
-       const void *p = dev->driver->board_name;
        const struct apci1516_boardinfo *this_board;
        int i;
 
        for (i = 0; i < dev->driver->num_names; i++) {
-               this_board = p;
-               if (this_board->vendor == pcidev->vendor &&
-                   this_board->device == pcidev->device)
+               this_board = &apci1516_boardtypes[i];
+               if (this_board->device == pcidev->device)
                        return this_board;
-               p += dev->driver->offset;
        }
        return NULL;
 }
@@ -80,7 +73,7 @@ static int __devinit apci1516_auto_attach(struct comedi_device *dev,
        struct comedi_subdevice *s;
        int ret;
 
-       this_board = addi_find_boardinfo(dev, pcidev);
+       this_board = apci1516_find_boardinfo(dev, pcidev);
        if (!this_board)
                return -ENODEV;
        dev->board_ptr = this_board;
@@ -169,9 +162,6 @@ static struct comedi_driver apci1516_driver = {
        .module         = THIS_MODULE,
        .auto_attach    = apci1516_auto_attach,
        .detach         = apci1516_detach,
-       .num_names      = ARRAY_SIZE(apci1516_boardtypes),
-       .board_name     = &apci1516_boardtypes[0].name,
-       .offset         = sizeof(struct apci1516_boardinfo),
 };
 
 static int __devinit apci1516_pci_probe(struct pci_dev *dev,