From f6fb3152f6e90141f6d3cf7199e570f1c884c3c2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 5 Mar 2013 09:56:06 -0700 Subject: [PATCH] --- yaml --- r: 363371 b: refs/heads/master c: 852f3378497265783e8a629cf3aa985f30be213d h: refs/heads/master i: 363369: 654a253be19ed7c47ecdc5c1e9dbe84fb3042f16 363367: 0ede5f66107a93534d5e11c310261301cfd09b7e v: v3 --- [refs] | 2 +- .../staging/comedi/drivers/addi_apci_1516.c | 52 +++++++------------ 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/[refs] b/[refs] index c18d2385b551..828cefeefb70 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: af48bd8ccece2c2605ea8cc4e4b69a916ec277f0 +refs/heads/master: 852f3378497265783e8a629cf3aa985f30be213d diff --git a/trunk/drivers/staging/comedi/drivers/addi_apci_1516.c b/trunk/drivers/staging/comedi/drivers/addi_apci_1516.c index df8f8ea243ff..0319315ba9bd 100644 --- a/trunk/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/trunk/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -35,13 +35,6 @@ #include "addi_watchdog.h" #include "comedi_fc.h" -/* - * PCI device ids supported by this driver - */ -#define PCI_DEVICE_ID_APCI1016 0x1000 -#define PCI_DEVICE_ID_APCI1516 0x1001 -#define PCI_DEVICE_ID_APCI2016 0x1002 - /* * PCI bar 1 I/O Register map - Digital input/output */ @@ -53,28 +46,32 @@ */ #define APCI1516_WDOG_REG 0x00 +enum apci1516_boardid { + BOARD_APCI1016, + BOARD_APCI1516, + BOARD_APCI2016, +}; + struct apci1516_boardinfo { const char *name; - unsigned short device; int di_nchan; int do_nchan; int has_wdog; }; static const struct apci1516_boardinfo apci1516_boardtypes[] = { - { + [BOARD_APCI1016] = { .name = "apci1016", - .device = PCI_DEVICE_ID_APCI1016, .di_nchan = 16, - }, { + }, + [BOARD_APCI1516] = { .name = "apci1516", - .device = PCI_DEVICE_ID_APCI1516, .di_nchan = 8, .do_nchan = 8, .has_wdog = 1, - }, { + }, + [BOARD_APCI2016] = { .name = "apci2016", - .device = PCI_DEVICE_ID_APCI2016, .do_nchan = 16, .has_wdog = 1, }, @@ -130,30 +127,17 @@ static int apci1516_reset(struct comedi_device *dev) return 0; } -static const void *apci1516_find_boardinfo(struct comedi_device *dev, - struct pci_dev *pcidev) -{ - const struct apci1516_boardinfo *this_board; - int i; - - for (i = 0; i < dev->driver->num_names; i++) { - this_board = &apci1516_boardtypes[i]; - if (this_board->device == pcidev->device) - return this_board; - } - return NULL; -} - static int apci1516_auto_attach(struct comedi_device *dev, - unsigned long context_unused) + unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct apci1516_boardinfo *this_board; + const struct apci1516_boardinfo *this_board = NULL; struct apci1516_private *devpriv; struct comedi_subdevice *s; int ret; - this_board = apci1516_find_boardinfo(dev, pcidev); + if (context < ARRAY_SIZE(apci1516_boardtypes)) + this_board = &apci1516_boardtypes[context]; if (!this_board) return -ENODEV; dev->board_ptr = this_board; @@ -241,9 +225,9 @@ static int apci1516_pci_probe(struct pci_dev *dev, } static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1016) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1516) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI2016) }, + { PCI_VDEVICE(ADDIDATA, 0x1000), BOARD_APCI1016 }, + { PCI_VDEVICE(ADDIDATA, 0x1001), BOARD_APCI1516 }, + { PCI_VDEVICE(ADDIDATA, 0x1002), BOARD_APCI2016 }, { 0 } }; MODULE_DEVICE_TABLE(pci, apci1516_pci_table);