summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/addi_apci_1516.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-03-05 09:56:06 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-11 10:01:44 -0700
commit852f3378497265783e8a629cf3aa985f30be213d (patch)
treea2379dd8e0e0c1d611e17c122b640d13973412c4 /drivers/staging/comedi/drivers/addi_apci_1516.c
parentaf48bd8ccece2c2605ea8cc4e4b69a916ec277f0 (diff)
staging: comedi: addi_apci_1516: use the pci id_table 'driver_data'
Create an enum to the boardinfo and pass that enum in the pci_driver id_table as the driver_data. Change the macro used to fill in the device table from PCI_DEVICE() to PCI_VDEVICE(). This allows passing the enum as the next field. This allows removing the 'device' data from the boardinfo as well the search function that was used to locate the boardinfo for the PCI device. Since the PCI device ids are now only used in the id_table, remove the defines and open code the device ids. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/addi_apci_1516.c')
-rw-r--r--drivers/staging/comedi/drivers/addi_apci_1516.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c
index df8f8ea243ff..0319315ba9bd 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1516.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1516.c
@@ -36,13 +36,6 @@
#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
*/
#define APCI1516_DI_REG 0x00
@@ -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);