static int ni_pcidio_cancel(struct comedi_device *dev,
struct comedi_subdevice *s);
+enum nidio_boardid {
+ BOARD_PCIDIO_32HS,
+ BOARD_PXI6533,
+ BOARD_PCI6534,
+};
+
struct nidio_board {
- int dev_id;
const char *name;
unsigned int uses_firmware:1;
};
static const struct nidio_board nidio_boards[] = {
- {
- .dev_id = 0x1150,
+ [BOARD_PCIDIO_32HS] = {
.name = "pci-dio-32hs",
- }, {
- .dev_id = 0x1320,
+ },
+ [BOARD_PXI6533] = {
.name = "pxi-6533",
- }, {
- .dev_id = 0x12b0,
+ },
+ [BOARD_PCI6534] = {
.name = "pci-6534",
.uses_firmware = 1,
},
return ret;
}
-static const struct nidio_board *
-nidio_find_boardinfo(struct pci_dev *pcidev)
-{
- unsigned int dev_id = pcidev->device;
- unsigned int n;
-
- for (n = 0; n < ARRAY_SIZE(nidio_boards); n++) {
- const struct nidio_board *board = &nidio_boards[n];
- if (board->dev_id == dev_id)
- return board;
- }
- return NULL;
-}
-
static int nidio_auto_attach(struct comedi_device *dev,
- unsigned long context_unused)
+ unsigned long context)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ const struct nidio_board *board = NULL;
struct nidio96_private *devpriv;
struct comedi_subdevice *s;
int ret;
unsigned int irq;
+ if (context < ARRAY_SIZE(nidio_boards))
+ board = &nidio_boards[context];
+ if (!board)
+ return -ENODEV;
+ dev->board_ptr = board;
+ dev->board_name = this_board->name;
+
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
spin_lock_init(&devpriv->mite_channel_lock);
- dev->board_ptr = nidio_find_boardinfo(pcidev);
- if (!dev->board_ptr)
- return -ENODEV;
devpriv->mite = mite_alloc(pcidev);
if (!devpriv->mite)
return -ENOMEM;
if (devpriv->di_mite_ring == NULL)
return -ENOMEM;
- dev->board_name = this_board->name;
irq = mite_irq(devpriv->mite);
if (this_board->uses_firmware) {
ret = pci_6534_upload_firmware(dev);
}
static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) },
- { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) },
- { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0) },
+ { PCI_VDEVICE(NI, 0x1150), BOARD_PCIDIO_32HS },
+ { PCI_VDEVICE(NI, 0x12b0), BOARD_PCI6534 },
+ { PCI_VDEVICE(NI, 0x1320), BOARD_PXI6533 },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);