From b5357e6111b6400852ce1d47c11cc9325d68bd02 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 5 Mar 2013 09:59:07 -0700 Subject: [PATCH] staging: comedi: adl_pci7x3x: 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 Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci7x3x.c | 76 ++++++++------------ 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/staging/comedi/drivers/adl_pci7x3x.c index b8dd161136a..70f8c93ef7a 100644 --- a/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -52,61 +52,58 @@ Configuration Options: not applicable, uses comedi PCI auto config #include "../comedidev.h" -/* - * PCI Device ID's supported by this driver - */ -#define PCI_DEVICE_ID_PCI7230 0x7230 -#define PCI_DEVICE_ID_PCI7233 0x7233 -#define PCI_DEVICE_ID_PCI7234 0x7234 -#define PCI_DEVICE_ID_PCI7432 0x7432 -#define PCI_DEVICE_ID_PCI7433 0x7433 -#define PCI_DEVICE_ID_PCI7434 0x7434 - /* * Register I/O map (32-bit access only) */ #define PCI7X3X_DIO_REG 0x00 #define PCI743X_DIO_REG 0x04 +enum apci1516_boardid { + BOARD_PCI7230, + BOARD_PCI7233, + BOARD_PCI7234, + BOARD_PCI7432, + BOARD_PCI7433, + BOARD_PCI7434, +}; + struct adl_pci7x3x_boardinfo { const char *name; - unsigned short device; int nsubdevs; int di_nchan; int do_nchan; }; static const struct adl_pci7x3x_boardinfo adl_pci7x3x_boards[] = { - { + [BOARD_PCI7230] = { .name = "adl_pci7230", - .device = PCI_DEVICE_ID_PCI7230, .nsubdevs = 2, .di_nchan = 16, .do_nchan = 16, - }, { + }, + [BOARD_PCI7233] = { .name = "adl_pci7233", - .device = PCI_DEVICE_ID_PCI7233, .nsubdevs = 1, .di_nchan = 32, - }, { + }, + [BOARD_PCI7234] = { .name = "adl_pci7234", - .device = PCI_DEVICE_ID_PCI7234, .nsubdevs = 1, .do_nchan = 32, - }, { + }, + [BOARD_PCI7432] = { .name = "adl_pci7432", - .device = PCI_DEVICE_ID_PCI7432, .nsubdevs = 2, .di_nchan = 32, .do_nchan = 32, - }, { + }, + [BOARD_PCI7433] = { .name = "adl_pci7433", - .device = PCI_DEVICE_ID_PCI7433, .nsubdevs = 2, .di_nchan = 64, - }, { + }, + [BOARD_PCI7434] = { .name = "adl_pci7434", - .device = PCI_DEVICE_ID_PCI7434, .nsubdevs = 2, .do_nchan = 64, } @@ -150,31 +147,18 @@ static int adl_pci7x3x_di_insn_bits(struct comedi_device *dev, return insn->n; } -static const void *adl_pci7x3x_find_boardinfo(struct comedi_device *dev, - struct pci_dev *pcidev) -{ - const struct adl_pci7x3x_boardinfo *board; - int i; - - for (i = 0; i < ARRAY_SIZE(adl_pci7x3x_boards); i++) { - board = &adl_pci7x3x_boards[i]; - if (pcidev->device == board->device) - return board; - } - return NULL; -} - static int adl_pci7x3x_auto_attach(struct comedi_device *dev, - unsigned long context_unused) + unsigned long context) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct adl_pci7x3x_boardinfo *board; + const struct adl_pci7x3x_boardinfo *board = NULL; struct comedi_subdevice *s; int subdev; int nchan; int ret; - board = adl_pci7x3x_find_boardinfo(dev, pcidev); + if (context < ARRAY_SIZE(adl_pci7x3x_boards)) + board = &adl_pci7x3x_boards[context]; if (!board) return -ENODEV; dev->board_ptr = board; @@ -300,12 +284,12 @@ static int adl_pci7x3x_pci_probe(struct pci_dev *dev, } static DEFINE_PCI_DEVICE_TABLE(adl_pci7x3x_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7233) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7234) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7433) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7434) }, + { PCI_VDEVICE(ADLINK, 0x7230), BOARD_PCI7230 }, + { PCI_VDEVICE(ADLINK, 0x7233), BOARD_PCI7233 }, + { PCI_VDEVICE(ADLINK, 0x7234), BOARD_PCI7234 }, + { PCI_VDEVICE(ADLINK, 0x7432), BOARD_PCI7432 }, + { PCI_VDEVICE(ADLINK, 0x7433), BOARD_PCI7433 }, + { PCI_VDEVICE(ADLINK, 0x7434), BOARD_PCI7434 }, { 0 } }; MODULE_DEVICE_TABLE(pci, adl_pci7x3x_pci_table); -- 2.46.0