Commit 6d6d443c authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: ni_pcidio: 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 'dev_id' data from the boardinfo as well the
search function that was used to locate the boardinfo for the PCI device.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3bac78ca
......@@ -280,21 +280,25 @@ enum FPGA_Control_Bits {
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,
},
......@@ -1094,29 +1098,23 @@ static int pci_6534_upload_firmware(struct comedi_device *dev)
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;
......@@ -1124,9 +1122,6 @@ static int nidio_auto_attach(struct comedi_device *dev,
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;
......@@ -1141,7 +1136,6 @@ static int nidio_auto_attach(struct comedi_device *dev,
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);
......@@ -1227,9 +1221,9 @@ static int ni_pcidio_pci_probe(struct pci_dev *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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment