Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363396
b: refs/heads/master
c: 6d6d443
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent dd95ee3 commit 7ad879c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3bac78caf1f70fb93d3021d86cca83ee783e35c0
refs/heads/master: 6d6d443cb29671c5bb1d67cbbaacbfc503409581
52 changes: 23 additions & 29 deletions trunk/drivers/staging/comedi/drivers/ni_pcidio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -1094,39 +1098,30 @@ 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;
dev->private = devpriv;

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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7ad879c

Please sign in to comment.