提交 f7c929b7 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

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: NH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 43ba2131
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册