summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-03-05 17:17:31 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-11 17:03:34 (GMT)
commit6d6d443cb29671c5bb1d67cbbaacbfc503409581 (patch)
tree20b1c09a2ed6559790e4018a4bd80a4fa5a49053
parent3bac78caf1f70fb93d3021d86cca83ee783e35c0 (diff)
downloadlinux-fsl-qoriq-6d6d443cb29671c5bb1d67cbbaacbfc503409581.tar.xz
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: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/ni_pcidio.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index f4d3fab..2c7538b 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -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);