diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-03-05 10:24:43 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-11 10:05:23 -0700 |
commit | f7c929b7fb3afde17997b997d17fa7846777c69d (patch) | |
tree | 4569825f07257e9b0af841217999b9202eb49e0e /drivers | |
parent | 43ba213156dba3afb4c8367da16c3d90aa87d2f8 (diff) | |
download | lwn-f7c929b7fb3afde17997b997d17fa7846777c69d.tar.gz lwn-f7c929b7fb3afde17997b997d17fa7846777c69d.zip |
staging: comedi: addi_apci_3200: 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.
Set the dev->board_ptr before calling addi_auto_attach(). This
removes the need for the common code to search for the boardinfo.
Since the search is not done we can remove the unnecessary board
information from the comedi_driver.
For aesthetic reasons, move the pci device table near the pci_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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/addi_apci_3200.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/addi_apci_3200.c b/drivers/staging/comedi/drivers/addi_apci_3200.c index a28bcbdffe07..e23831bcec4d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3200.c +++ b/drivers/staging/comedi/drivers/addi_apci_3200.c @@ -22,8 +22,13 @@ static void fpu_end(void) #include "addi-data/hwdrv_apci3200.c" #include "addi-data/addi_common.c" +enum apci3200_boardid { + BOARD_APCI3200, + BOARD_APCI3300, +}; + static const struct addi_board apci3200_boardtypes[] = { - { + [BOARD_APCI3200] = { .pc_DriverName = "apci3200", .i_VendorId = PCI_VENDOR_ID_ADDIDATA, .i_DeviceId = 0x3000, @@ -53,7 +58,8 @@ static const struct addi_board apci3200_boardtypes[] = { .ai_cancel = i_APCI3200_StopCyclicAcquisition, .di_bits = apci3200_di_insn_bits, .do_bits = apci3200_do_insn_bits, - }, { + }, + [BOARD_APCI3300] = { .pc_DriverName = "apci3300", .i_VendorId = PCI_VENDOR_ID_ADDIDATA, .i_DeviceId = 0x3007, @@ -85,21 +91,25 @@ static const struct addi_board apci3200_boardtypes[] = { }, }; -static DEFINE_PCI_DEVICE_TABLE(apci3200_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3000) }, - { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3007) }, - { 0 } -}; -MODULE_DEVICE_TABLE(pci, apci3200_pci_table); +static int apci3200_auto_attach(struct comedi_device *dev, + unsigned long context) +{ + const struct addi_board *board = NULL; + + if (context < ARRAY_SIZE(apci3200_boardtypes)) + board = &apci3200_boardtypes[context]; + if (!board) + return -ENODEV; + dev->board_ptr = board; + + return addi_auto_attach(dev, context); +} static struct comedi_driver apci3200_driver = { .driver_name = "addi_apci_3200", .module = THIS_MODULE, - .auto_attach = addi_auto_attach, + .auto_attach = apci3200_auto_attach, .detach = i_ADDI_Detach, - .num_names = ARRAY_SIZE(apci3200_boardtypes), - .board_name = &apci3200_boardtypes[0].pc_DriverName, - .offset = sizeof(struct addi_board), }; static int apci3200_pci_probe(struct pci_dev *dev, @@ -108,6 +118,13 @@ static int apci3200_pci_probe(struct pci_dev *dev, return comedi_pci_auto_config(dev, &apci3200_driver, id->driver_data); } +static DEFINE_PCI_DEVICE_TABLE(apci3200_pci_table) = { + { PCI_VDEVICE(ADDIDATA, 0x3000), BOARD_APCI3200 }, + { PCI_VDEVICE(ADDIDATA, 0x3007), BOARD_APCI3300 }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, apci3200_pci_table); + static struct pci_driver apci3200_pci_driver = { .name = "addi_apci_3200", .id_table = apci3200_pci_table, |